-
Notifications
You must be signed in to change notification settings - Fork 5
/
main_interface
105 lines (82 loc) · 3.07 KB
/
main_interface
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var geometry =
/* color: #d63000 */
/* shown: false */
ee.Geometry.MultiPoint();
/***** End of imports. If edited, may not auto-convert in the playground. *****/
// released under Open Source GPL License Copyright © 2023 Ka Hei Chow
// import module
var style = require('users/pinkychow1010/WB_IntraUrban:main_style');
var txt = require('users/pinkychow1010/WB_IntraUrban:main_text');
var app = require('users/pinkychow1010/WB_IntraUrban:app_func');
var config = require('users/pinkychow1010/WB_IntraUrban:analysis_tool_config');
app.set_up(); // map initial set up
// predefined functionalities
var app_action_dict = config.app_action_dict;
// dict for app analysis description
var app_info_dict = config.app_info_dict;
// Function to switch from main page to app page
function changeApp(value) {
var selected_app = selection.getValue(); // get user selection
main_page.clear(); // remove main page
app_action_dict[selected_app](); // call function according to action dict
}
// Initial description (empty)
var desciption_label = ui.Label({value: "", style: style.description});
// Change decription based on the app user selects
function changeDescription(value) {
desciption_label.setValue(app_info_dict[value]);
return(value);
}
// Drop-down menu for app selection
var selection = ui.Select({
placeholder: 'Select analysis to begin with...',
items: Object.keys(app_info_dict),
style: style.selection,
onChange: changeDescription
});
// Config side bar
function createPanel(selection, description_label) {
// app main title
var title = ui.Label({
value: 'Climate Hazard Analysis Tool',
style: style.title
});
// headings
var description = ui.Label({
value: txt.headings,
style: style.headings
});
// set consistent background color for all elements
selection.style().set('backgroundColor', style.bg_color);
title.style().set('backgroundColor', style.bg_color);
description.style().set('backgroundColor', style.bg_color);
description_label.style().set('backgroundColor', style.bg_color);
// jump to analysis interface
var start_button = ui.Button({
label: "Get started",
style: style.start_button,
onClick: changeApp
});
// panel for app selection and switch interface
var app = ui.Panel({
layout: ui.Panel.Layout.flow('horizontal'),
style: style.app_panel
});
app.add(selection);
app.add(start_button);
app.style().set('backgroundColor', style.bg_color);
// set layouts
var content = ui.Panel([
title, description, app, description_label
], null, {stretch:'vertical'});
content.style().set('backgroundColor', style.bg_color);
content.style().set('whiteSpace', 'pre');
var page = ui.Panel([content]);
page.style().set('backgroundColor', style.bg_color);
return page;
}
// call the main page
var main_page = createPanel(selection, desciption_label);
//ui.root.clear()
ui.root.add(main_page);