Skip to content

Commit

Permalink
Model configurator pt1 (#10)
Browse files Browse the repository at this point in the history
Big pull from MINT-UI includes:

* fixed mintproject/mint-ui-lit#145

* Clean up region query modules. Parameter Validation

* Forgot to commit files :)

* Max 100 runs per analyst

* fixed mintproject/mint-ui-lit#134

* Handling multiple fixed value datasets in model configuration setup

* bug fixes

* regions API and showing regions

* Release 3.0.0

* Release 3.0.1

* Extracting all apis to preferences

* Extracting apis into prefs

* fixed mintproject/mint-ui-lit#150

* Text and style changes

* partial fix for mintproject/mint-ui-lit#151

* Added indicators for pihm and topoflow

* autologin

* Handle multiple threads per task in reports

* Changing the main page text

* Fixed mintproject/mint-ui-lit#154

* Changed generic viz to use the new 'upload' dashboard

* Added text for remote sensing workflows

* Remove extra wings logins + keep the check status button visible

* bugfixes

* Fixed mintproject/mint-ui-lit#155

* Fixed mintproject/mint-ui-lit#156

* Fixed mintproject/mint-ui-lit#157

* Fixed mintproject/mint-ui-lit#148 with static data

* Visual improvement for mintproject/mint-ui-lit#151

* Increasing number of runs for analysts to 300

* Bugfix

* Doing a region query across models

* Pathway subscription bug

* Adding usage notes

* Fix run summary text

* Added Hand indicator to MINT-UI

* Showing adjustable variable in task + model selection

* Changed 'Select & Continue' to 'Select & Run' in Setup

* Showing regions in categories

* addition of explanatory text

* bugfix

* Showing default viz for cycles too

* Add indicator for topoflow

* Fix link to models from regions

* Fix ensembles not being removed on model removed

* Fix ensembleids subcollection not being deleted on scenario deletion

* Bug fixes with multi-model multi-dataset runs + parameter positioning

* Added emulators button

* Missing files for emulators

* bugfix

* Regions Viewer fix

* Added topoflow details in model products/emulators

* added SampleResource

* Sorting message threads by timestamp

* Change the emulators page

* Adding intervention details

* Showing messages only when a region is selected, or messages dont show up

* Add option to show all outputs

* fixed select authors

* Prettify Problem statement listing

* Removing Season crop production index from indicators

* Cleaner Task Description

* Cleaner Tasks

* Region cleanup + Trimming resources that are strictly within geojson polygon, not just bounding box

* Using the Data Catalog API to query polygon

* Restricting region query to within datasets

* Fixing tooltips, region for parameters and styles

* configure parameter ranges

* Dataset Specification editable on config

* Added SampleCollection editor, and fixed mintproject/mint-ui-lit#162

* editable inputs

* add multiple files as input of new setups

* fixing inputs

* setup now creates all parameters

* Moving to ensemble manager

* POST setup almost working

* Adding texas bounding boxes

* Show all results by default

* Get the user to select & continue even if no datasets and parameters are needed

* Bugfix

* Bugfix

* disabling setup creation

* Fixed issue making inputs load forever

* Re-enabling datatype matching

* Added extra indicators

* fixed region filter on configure models

* Runs not done till all successful

* Conection with model-catalog and data-catalog on Explore Areas

* Fixing a issue preventing the dataset description to load sometimes

* Added multiple regions or countries as parameters to filter visible setups

* Always show dataset with transformations

* updated data-transformation url

* Handling ensemble updates for ingestion

* Handling ensemble updates for ingestion - 2

* Using images visualization for more indicators

* Initial emulators information

* Changed emulators page

* Changed emulators page

* Using images visualization for more indicators

* Enable setup creation

* sort parameters by position in run/results table

* fixed adjustable parameters for new setups and other bugs

* Woredas regions added

* Woredas only for South Sudan

* Introduction link updated

* Added download button on pathway-results

* Fixed model catalog URLs

* Fixed error handling on promises for model-catalog-api

* Fixed setup creation when the config has no parameters

* Added custom region subcategories

* Added placeholder button to download datasets to MINT servers

* Fixing types

* mintproject/mint-ui-lit#185

* Fixed mintproject/mint-ui-lit#186

* Fixed mintproject/mint-ui-lit#188

* Improved model tree, fixed mintproject/mint-ui-lit#189

* Using submitted_for_execution to check as well

* Region category on main tab

* Added dataset repr json data

* Fixed model search when some model does not have bounding box

* Fixing types

* Fixed mintproject/mint-ui-lit#198

* Data catalog request changes part 1

* Updated to model-catalog 1.4.1

* Added result show/total on dataset details

* Fixed mintproject/mint-ui-lit#199

* Time interval details

* Disabling new setup until PUT error fix

* Fixed mintproject/mint-ui-lit#147

* Transformation example

* Fixing mintproject/mint-ui-lit#199 and other bugs, enabling setup creation.

* Fixed dataset details

* Fixed dataset search by variable

* Fixes for the new Data Catalog API

* Use input url

* New region categories

* Added region categories description and citation

* Region selection on new setup

* Fixed dataset search, time coverage now is optional

* Fixed time coverage on dataset resources

* Changing type of setups to ModelConfigurationSetup and added region selector.

* Fix for run list not updating on initial run

* Added map on region configuration

* Select multiple regions on setup creation.

* Added static pages

* Some bugfixes + showing the region id

* Some Hardcoded emulator details

* Fixed order of parameters on model-view

* Updated versions + Adding position to ModelIO as well

* Release 4.0.0-0

* Removed duplicated images

* Fixed front page links

* Release 4.0.0-1

* Fixed mintproject/mint-ui-lit#233 added option to edit configuration defaults

* Fixed mintproject/mint-ui-lit#225

* Provide URL for emulator tabs + add cycles emulators

* Updated packages

* Add emulators actions and reducers

* add release-it config

* Release 4.0.0-2

* Fixed mintproject/mint-ui-lit#239

* Fixed mintproject/mint-ui-lit#238

* Fixed mintproject/mint-ui-lit#236

* Fix error when selecting no region category

* Fixed mintproject/mint-ui-lit#237

* Removed task on regions screen and added help tooltip

* Changed URL for data-transformations

* Fixed dataset resources loading screen

* Added new indicators

* Fixing bugs (#273)

* Fixed mintproject/mint-ui-lit#254

* Fixed mintproject/mint-ui-lit#258 and mintproject/mint-ui-lit#259

* Fixed mintproject/mint-ui-lit#261 and mintproject/mint-ui-lit#260

* Fixed mintproject/mint-ui-lit#270

* Fixed mintproject/mint-ui-lit#262

* Fixed text of mintproject/mint-ui-lit#270 (#274)

* Fixed configure titles (#280)

* Links to documentation and more search model options (#281)

* Links to new documentation

* Added other ways to search models (index, intervention, region) but using fetch

* Fixed mintproject/mint-ui-lit#267 (#282)

* Hotfix (#283)

* Better links for documentation

* Fixed return links when editing configuration

* Change text of full-text search mintproject/mint-ui-lit#264

* Fixed documentation link. (#284)

* Fix model search on Explore Areas (#293)

* Model catalog refactoring pt1 (#295)

* Refactoring regions

* Refactoring most of the model-catalog resources

* Refactoring configuration and setup

* Cleaning configure main and fixed load order

* General parameters table

* Fixing links and loading parameters

* Refactoring model-preview

* Only show subregions of the top-level region on the model catalog.

* New way to compute model URLs based on parent_region

* Loading images from model-catalog

* Added preferred region

* Fix errors on modeling

* Default preferred region

* Updated to model-catalog client 1.7.2 (#299)

* Refactoring regions

* Refactoring most of the model-catalog resources

* Refactoring configuration and setup

* Cleaning configure main and fixed load order

* General parameters table

* Fixing links and loading parameters

* Refactoring model-preview

* Only show subregions of the top-level region on the model catalog.

* New way to compute model URLs based on parent_region

* Loading images from model-catalog

* Added preferred region

* Fix errors on modeling

* default preferred region

* Updated to model-catalog 1.7.2

* Disable model creation

* Fixed filter of parent region country -> partOf

* Typo on executable on mint...

* UI changes (#305)

* Fixed mintproject/mint-ui-lit#251

* Partial fix for mintproject/mint-ui-lit#231

* model-view to previus version to fix errors (#308)

Co-authored-by: Varun Ratnakar <varunratnakar@gmail.com>
Co-authored-by: Maximiliano Osorio <maxiosorio@gmail.com>
  • Loading branch information
3 people committed Mar 10, 2020
1 parent c12af55 commit a33e9c8
Show file tree
Hide file tree
Showing 112 changed files with 16,950 additions and 4,232 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
11 changes: 7 additions & 4 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "mint-ui-lit",
"version": "1.0.0",
"version": "4.0.0-2",
"description": "MINT UI",
"author": "Varun Ratnakar",
"license": "MIT",
Expand All @@ -16,23 +16,26 @@
},
"dependencies": {
"@babel/runtime-corejs2": "^7.3.1",
"@mintproject/modelcatalog_client": "^1.7.2",
"@polymer/app-layout": "^3.0.2",
"@polymer/polymer": "^3.1.0",
"@types/codemirror": "^0.0.78",
"@webcomponents/webcomponentsjs": "^2.2.7",
"codemirror": "^5.49.0",
"codemirror-spell-checker": "^1.1.2",
"easymde": "^2.8.0",
"firebase": "^6.2.0",
"lit-element": "^2.0.1",
"firebase": "^7.7.0",
"lit-element": "^2.2.1",
"marked": "^0.7.0",
"moment": "^2.24.0",
"multiselect-combo-box": "^2.0.2",
"pwa-helpers": "^0.9.0",
"redux": "^4.0.0",
"redux-thunk": "^2.3.0",
"reselect": "^4.0.0",
"ts-md5": "^1.2.6",
"tslib": "^1.9.3",
"weightless": "0.0.34"
"weightless": "0.0.37"
},
"devDependencies": {
"@babel/core": "^7.2.2",
Expand Down
Binary file removed src/.DS_Store
Binary file not shown.
154 changes: 125 additions & 29 deletions src/app/actions.ts
Expand Up @@ -11,49 +11,86 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
import { Action, ActionCreator } from 'redux';
import { ThunkAction } from 'redux-thunk';
import { RootState, store } from './store';
import { queryDatasetDetail } from '../screens/datasets/actions';
import { queryModelDetail } from '../screens/models/actions';
import { explorerClearModel, explorerSetModel, explorerSetVersion, explorerSetConfig,
explorerSetCalibration, explorerSetMode } from '../screens/models/model-explore/ui-actions';
import { selectScenario, selectPathway, selectSubgoal, selectPathwaySection, selectTopRegion, selectThread } from './ui-actions';
import { auth } from '../config/firebase';
import { auth, db } from '../config/firebase';
import { User } from 'firebase';
import { UserPreferences } from './reducers';
import { SAMPLE_USER_PREFERENCES, SAMPLE_USER } from 'offline_data/sample_user';
import { UserPreferences, MintPreferences, UserProfile } from './reducers';
import { DefaultApi } from '@mintproject/modelcatalog_client';
import { dexplorerSelectDataset, dexplorerSelectDatasetArea } from 'screens/datasets/ui-actions';
import { selectEmulatorModel } from 'screens/emulators/actions';

export const BASE_HREF = document.getElementsByTagName("base")[0].href.replace(/^http(s)?:\/\/.*?\//, "/");

export const UPDATE_PAGE = 'UPDATE_PAGE';
export const LOGIN = 'LOGIN';
export const LOGOUT = 'LOGOUT';
export const FETCH_USER = 'FETCH_USER';
export const FETCH_USER_PREFERENCES = 'FETCH_USER_PREFERENCES';
export const FETCH_USER_PROFILE = 'FETCH_USER_PROFILE';
export const FETCH_MINT_CONFIG = 'FETCH_MINT_CONFIG';
export const FETCH_MODEL_CATALOG_ACCESS_TOKEN = 'FETCH_MODEL_CATALOG_ACCESS_TOKEN';
export const STATUS_MODEL_CATALOG_ACCESS_TOKEN = 'STATUS_MODEL_CATALOG_ACCESS_TOKEN';

export interface AppActionUpdatePage extends Action<'UPDATE_PAGE'> { regionid?: string, page?: string, subpage?:string };
export interface AppActionFetchUser extends Action<'FETCH_USER'> { user?: User | null };
export interface AppActionFetchUserPreferences extends Action<'FETCH_USER_PREFERENCES'> {
prefs?: UserPreferences | null
export interface AppActionFetchUserPreferences extends Action<'FETCH_USER_PROFILE'> { profile?: UserProfile };
export interface AppActionFetchMintConfig extends Action<'FETCH_MINT_CONFIG'> {
prefs?: MintPreferences | null
};
export interface AppActionFetchModelCatalogAccessToken extends Action<'FETCH_MODEL_CATALOG_ACCESS_TOKEN'> {
accessToken: string
};
export interface AppActionStatusModelCatalogAccessToken extends Action<'STATUS_MODEL_CATALOG_ACCESS_TOKEN'> {
status: string
};

export type AppAction = AppActionUpdatePage | AppActionFetchUser | AppActionFetchUserPreferences;
export type AppAction = AppActionUpdatePage | AppActionFetchUser | AppActionFetchUserPreferences | AppActionFetchMintConfig |
AppActionFetchModelCatalogAccessToken | AppActionStatusModelCatalogAccessToken;

type ThunkResult = ThunkAction<void, RootState, undefined, AppAction>;

export const OFFLINE_DEMO_MODE = false;

/* This retrieve the user profile from the db. Maybe we should move this to other file. */
type UserProfileThunkResult = ThunkAction<void, RootState, undefined, AppActionFetchUserPreferences>;
export const fetchUserProfile: ActionCreator<UserProfileThunkResult> = (user:User) => (dispatch) => {
let ref = db.collection('users').doc(user.email);
ref.get().then((qs) => {
let profile = qs.data();
if (profile) {
dispatch({
type: FETCH_USER_PROFILE,
profile: profile as UserProfile
});
}
})
}

type UserThunkResult = ThunkAction<void, RootState, undefined, AppActionFetchUser>;
export const fetchUser: ActionCreator<UserThunkResult> = () => (dispatch) => {
if(OFFLINE_DEMO_MODE) {
dispatch({
type: FETCH_USER,
user: SAMPLE_USER as User
});
return;
}

//console.log("Subscribing to user authentication updates");
auth.onAuthStateChanged(user => {
if (user) {
// Check the state of the model-catalog access token.
let state: any = store.getState();
if (!state.app.prefs.modelCatalog.status) {
// This happen when we are already auth on firebase, the access token should be on local storage
let accessToken = localStorage.getItem('accessToken');
if (accessToken) {
store.dispatch({type: FETCH_MODEL_CATALOG_ACCESS_TOKEN, accessToken: accessToken});
} else {
console.error('No access token on local storage!')
// Should log out
}
} else if (state.app.prefs.modelCatalog.status === 'ERROR') {
console.error('Login failed!');
// Should log out
}

dispatch(fetchUserProfile(user));

dispatch({
type: FETCH_USER,
user: user
Expand All @@ -67,26 +104,64 @@ export const fetchUser: ActionCreator<UserThunkResult> = () => (dispatch) => {
});
};

type UserPrefsThunkResult = ThunkAction<void, RootState, undefined, AppActionFetchUserPreferences>;
export const fetchUserPreferences: ActionCreator<UserPrefsThunkResult> = () => (dispatch) => {
//if(OFFLINE_DEMO_MODE) {
dispatch({
type: FETCH_USER_PREFERENCES,
prefs: SAMPLE_USER_PREFERENCES
});
return;
//}
type UserPrefsThunkResult = ThunkAction<void, RootState, undefined, AppActionFetchMintConfig>;
export const fetchMintConfig: ActionCreator<UserPrefsThunkResult> = () => (dispatch) => {
db.doc("configs/main").get().then((doc) => {
let prefs = doc.data() as MintPreferences;
if(prefs.execution_engine == "wings") {
fetch(prefs.wings.server + "/config").then((res) => {
res.json().then((wdata) => {
prefs.wings.export_url = wdata["internal_server"]
prefs.wings.storage = wdata["storage"];
prefs.wings.dotpath = wdata["dotpath"];
prefs.wings.onturl = wdata["ontology"];
dispatch({
type: FETCH_MINT_CONFIG,
prefs: prefs
});
})
})
}
else {
dispatch({
type: FETCH_MINT_CONFIG,
prefs: prefs
});
}
})
return;
};

export const signIn = (email: string, password: string) => {
auth
.signInWithEmailAndPassword(email, password);
auth.signInWithEmailAndPassword(email, password);
modelCatalogLogin(email, password);
};

export const signOut = () => {
auth.signOut();
localStorage.removeItem('accessToken');
};

const modelCatalogLogin = (username: string, password: string) => {
let API = new DefaultApi();
store.dispatch({type: STATUS_MODEL_CATALOG_ACCESS_TOKEN, status: 'LOADING'})
API.userLoginGet({username: username, password: password})
.then((data:any) => {
let accessToken : string = JSON.parse(data)['access_token'];
if (accessToken) {
localStorage.setItem('accessToken', accessToken);
console.log('NEW TOKEN:', accessToken);
store.dispatch({type: FETCH_MODEL_CATALOG_ACCESS_TOKEN, accessToken: accessToken});
} else {
store.dispatch({type: STATUS_MODEL_CATALOG_ACCESS_TOKEN, status: 'ERROR'})
console.error('Error fetching the model catalog token!');
}
})
.catch((err) => {
console.log('Error login to the model catalog', err)
store.dispatch({type: STATUS_MODEL_CATALOG_ACCESS_TOKEN, status: 'ERROR'})
});
}

export const goToPage = (page:string) => {
let url = BASE_HREF + page;
Expand All @@ -95,7 +170,6 @@ export const goToPage = (page:string) => {
}

export const navigate: ActionCreator<ThunkResult> = (path: string) => (dispatch) => {
console.log(path);
// Extract the page name from path.
let cpath = path === BASE_HREF ? '/home' : path.slice(BASE_HREF.length);
let page = cpath.substr(0);
Expand All @@ -111,7 +185,7 @@ export const navigate: ActionCreator<ThunkResult> = (path: string) => (dispatch)
params.splice(0, 1);
}

dispatch(loadPage(page, subpage, params));
store.dispatch(loadPage(page, subpage, params));
};

const loadPage: ActionCreator<ThunkResult> =
Expand Down Expand Up @@ -152,6 +226,28 @@ const loadPage: ActionCreator<ThunkResult> =
store.dispatch(explorerClearModel());
}
});
} else if (subpage == 'configure') {
import('../screens/models/models-configure').then((_module) => {
if (params[params.length -1] === 'edit' || params[params.length -1] === 'new') {
store.dispatch(explorerSetMode(params.pop()));
} else {
store.dispatch(explorerSetMode('view'));
}
if(params.length > 0) {
store.dispatch(explorerSetModel(params[0]));
if (params.length > 1) {
store.dispatch(explorerSetVersion(params[1]));
if (params.length > 2) {
store.dispatch(explorerSetConfig(params[2]));
if (params.length > 3) {
store.dispatch(explorerSetCalibration(params[3]));
}
}
}
} else {
store.dispatch(explorerClearModel());
}
});
}
break;
default:
Expand Down

0 comments on commit a33e9c8

Please sign in to comment.