Skip to content

Commit

Permalink
Merge pull request #578 from jolevesq/556-cloud
Browse files Browse the repository at this point in the history
fix(cloud): Fix url to work in the cloud, pluf cloud downoad issue an…
  • Loading branch information
jolevesq authored Mar 11, 2021
2 parents a43abd0 + 08b4ffd commit 5242e69
Show file tree
Hide file tree
Showing 18 changed files with 282 additions and 81 deletions.
17 changes: 17 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\src\\app\\ui\\forms\\form.service.js"
}
]
}
2 changes: 1 addition & 1 deletion src/app/core/constant.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ angular
keys: ['coordInfo', 'areasOfInterest', 'rangeSlider', 'chart', 'swiper', 'draw', 'thematicSlider']
}
},
devVersion: '3.3.1',
devVersion: '3.3.2',
prodVersion: '3.2.0'
}); // TODO: add new tabs and subtabs as they come, tabs and subtabs listed as they should appear in the interface

Expand Down
11 changes: 7 additions & 4 deletions src/app/core/stateManager.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,12 +599,15 @@ function stateManager($translate, events, constants, commonService) {

// Because the url required is not trap by the validation, check it here
let valid = true;
for (let k = 0; k < item.legend.length; k++) {
if (item.legend[k].image.url === '') {
valid = false;
pluginVal = false;
if (typeof item.legend !== 'undefined') {
for (let k = 0; k < item.legend.length; k++) {
if (item.legend[k].image.url === '') {
valid = false;
pluginVal = false;
}
}
}

stateModel.items[6].items[7].items[j].valid = valid;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/ui/forms/map/map.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,9 @@ function Controller($scope, $translate, $timeout,
input.checked = true;
}

// make sure columns are empty
entry.table.columns = []

// FIXME: there so bugs with ASF.
// We are not able to set step value... we need to set them manually
$timeout(() => {
Expand Down
43 changes: 30 additions & 13 deletions src/app/ui/forms/plugins/plugins.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
{ 'key': 'rangeSlider.params.limit.staticItems', 'startEmpty': true, 'condition': 'model.rangeSlider.params.stepType === \'static\'' }
] }
] }
] }
] },
{ 'key': 'rangeSlider.params.units', 'condition': 'model.rangeSlider.enable === true' },
{ 'key': 'rangeSlider.params.description', 'condition': 'model.rangeSlider.enable === true' }
] },
{ 'key': 'rangeSlider.layers', 'add': $translate.instant('button.add'), 'condition': 'model.rangeSlider.enable === true', 'items': [
{ 'type': 'fieldset', 'htmlClass': 'av-rangeSlider', 'items': [
Expand Down Expand Up @@ -326,24 +328,24 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
{ value: 'linear', name: $translate.instant('form.plugins.chartlinear') }
] },
{ 'key': 'chart.axis.xAxis.title' },
{ 'key': 'chart.axis.xAxis.values' },
{ 'key': 'chart.axis.xAxis.split' }
{ 'key': 'chart.axis.xAxis.values', 'condition': 'model.chart.type !== "line"' },
{ 'key': 'chart.axis.xAxis.split', 'condition': 'model.chart.type !== "line" && model.chart.axis.xAxis.type === "config"' }
] },
{ 'key': 'chart.axis.yAxis', 'items': [
{ 'key': 'chart.axis.yAxis.type', 'titleMap': [
{ 'key': 'chart.axis.yAxis.type', 'condition': 'model.chart.enable === true && model.chart.type == "bar"', 'titleMap': [
{ value: 'config', name: $translate.instant('form.plugins.chartconfig') },
{ value: 'field', name: $translate.instant('form.plugins.chartfield') }
] },
{ 'key': 'chart.axis.yAxis.type', 'condition': 'model.chart.enable === true && model.chart.type == "line"', 'titleMap': [
{ value: 'linear', name: $translate.instant('form.plugins.chartlinear') }
] },
{ 'key': 'chart.axis.yAxis.title' },
{ 'key': 'chart.axis.yAxis.values' },
{ 'key': 'chart.axis.yAxis.split' }
{ 'key': 'chart.axis.yAxis.values', 'condition': 'model.chart.type !== "line"' },
{ 'key': 'chart.axis.yAxis.split', 'condition': 'model.chart.type !== "line" && model.chart.axis.yAxis.type === "config"' }
] }
] },
// TODO: re enable add when geoapi will support layer id. At the same time re enable layer id selection
// TODO: remove default value = 0 inside the schema
// TODO: remove layer id explanation
{ 'key': 'chart.layers', 'condition': 'model.chart.enable === true', 'add': null, 'items': [
{ 'type': 'fieldset', 'htmlClass': 'av-tileschema', 'readonly': true, 'items': [
{ 'type': 'fieldset', 'htmlClass': 'av-tileschema', 'items': [
{
'key': 'chart.layers[].id',
'type': 'dynamic-select',
Expand All @@ -352,19 +354,30 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
'array': true
}
] },
{ 'key': 'chart.layers[].nameField' },
{ 'key': 'chart.layers[].type', 'titleMap': [
{ value: 'inline', name: $translate.instant('form.plugins.chartinline') },
{ value: 'link', name: $translate.instant('form.plugins.chartlink') }
] },
{ 'key': 'chart.layers[].linkUrl', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].linkField', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].data', 'title': $translate.instant('form.plugins.chartdata'), 'htmlClass': 'av-accordion-all', 'startEmpty': true, 'onChange': () => {
// new item, create accordion
events.$broadcast(events.avNewItems);
}, 'add': $translate.instant('button.add'), 'items': [
{ 'type': 'fieldset', 'htmlClass': 'av-accordion-toggle', 'title': $translate.instant('form.plugins.chartdata'), 'items': [
{ 'type': 'help', 'htmlClass': 'av-form-advance hidden', 'helpvalue': '<div class="help-block">' + $translate.instant('form.map.expcoldesc') + '<div>' },
{ 'key': 'chart.layers[].data[]', 'htmlClass': `av-accordion-content`, 'notitle': true, 'items': [
{ 'key': 'chart.layers[].data[].type' },
{ 'key': 'chart.layers[].data[].type', 'condition': 'model.chart.layers[arrayIndex].type !== "link"' },
{ 'key': 'chart.layers[].data[].linkType', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].data[].link', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].data[].date', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].data[].values', 'condition': 'model.chart.layers[arrayIndex].type === "link"' },
{ 'key': 'chart.layers[].data[].measure', 'targetLink': 'legend.0', 'targetParent': 'av-accordion-toggle', 'default': $translate.instant('form.plugins.chartdata'), 'onChange': debounceService.registerDebounce((model, item) => {
self.formService.copyValueToFormIndex(model, item);}, constants.debInput, false)
},
{ 'key': 'chart.layers[].data[].regex' },
{ 'key': 'chart.layers[].data[].split' },
{ 'key': 'chart.layers[].data[].regex', 'condition': 'model.chart.layers[arrayIndex].type !== "link"' },
{ 'key': 'chart.layers[].data[].split', 'condition': 'model.chart.layers[arrayIndex].type !== "link"' },
{ 'key': 'chart.layers[].data[].label', 'condition': 'model.chart.enable === true && model.chart.type === "pie"', 'items': [
{ 'key': 'chart.layers[].data[].label.type', 'titleMap': [
{ value: 'config', name: $translate.instant('form.plugins.chartconfig') },
Expand All @@ -377,6 +390,10 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
{ 'key': 'chart.layers[].data[].suffix' }
] }
] }
] },
{ 'key': 'chart.layers[].details', 'items': [
{ 'key': 'chart.layers[].details.enabled' },
{ 'key': 'chart.layers[].details.value', 'condition': 'model.chart.layers[arrayIndex].details.enabled === true' }
] }
] }
] },
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/forms/services/services.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
{ 'type': 'template', 'template': self.formService.addCustomAccordion($translate.instant('form.custom.help'), `help/info-servicesurl-${commonService.getLang()}.md`, true) },
{ 'key': 'proxyUrl', 'htmlClass': 'av-form-advance hidden', 'readonly': true },
{ 'key': 'corsEverywhere', 'htmlClass': 'av-form-advance hidden', 'readonly': false },
{ 'key': 'exportMapUrl', 'htmlClass': 'av-form-advance hidden', 'readonly': true },
{ 'key': 'exportMapUrl', 'htmlClass': 'av-form-advance hidden', 'readonly': false },
{ 'key': 'geometryUrl', 'htmlClass': 'av-form-advance hidden', 'readonly': true },
{ 'key': 'googleAPIKey', 'htmlClass': 'av-form-advance hidden', 'readonly': true },
{ 'key': 'esriLibUrl', 'htmlClass': 'av-form-advance hidden', 'readonly': false }
Expand Down
1 change: 0 additions & 1 deletion src/app/ui/forms/version/version.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ function Controller($scope, $translate, events, modelManager, stateManager, form
*/
function setLocalVersion() {
localStorage.setItem('viewerversion', modelManager.getModel('version', false).version);
localStorage.setItem('viewerenv', modelManager.getModel('version', false).version === constants.devVersion ? 'dev' : '');
}

events.$on(events.avValidateForm, () => {
Expand Down
1 change: 0 additions & 1 deletion src/app/ui/summary/summary.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ function Controller($mdDialog, $rootScope, $timeout, $interval, events, constant
*/
function setLocalVersion() {
localStorage.setItem('viewerversion', modelManager.getModel('version', false).version);
localStorage.setItem('viewerenv', modelManager.getModel('version', false).version === constants.devVersion ? 'dev' : '');
}

/**
Expand Down
77 changes: 55 additions & 22 deletions src/content/samples/config/all-plugins-samplesv01.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,17 @@
}
],
"layers": [
{
"id": "WaterQuality***05003c79",
"name": "Water Quality",
"layerChoice": "esriDynamic",
"layerType": "esriDynamic",
"url": "https://maps-stage.services.geo.ca/server_serveur/rest/services/NRCAN/Water_Quality_Test2/MapServer",
"layerEntries": [{
"index": 0,
"name": "Points"
}]
},
{
"layerChoice": "esriFeature",
"layerType": "esriFeature",
Expand Down Expand Up @@ -987,32 +998,54 @@
]
},
"chart": {
"enable": false,
"type": "pie",
"title": "",
"labelsPie": {
"type": "config",
"type": "line",
"title": "Water Quality",
"axis": {
"xAxis": {
"type": "date",
"title": "Dates",
"values": "",
"split": ""
},
"yAxis": {
"type": "linear",
"title": "MG / L",
"values": "",
"split": ";"
"split": ""
}
},
"options": {
"colors": "",
"cutOut": 0
"colors": "",
"cutOut": 0
},
"axis": {
"xAxis": {
"title": "",
"type": "config",
"values": "",
"split": ";"
},
"yAxis": {
"title": "",
"type": "config",
"values": "",
"split": ";"
"layers": [{
"id": "WaterQuality***05003c79",
"nameField": "Site_number",
"type": "link",
"linkUrl": "https://maps-stage.services.geo.ca/server_serveur/rest/services/NRCAN/Water_Quality_Test2/MapServer/1",
"linkField": "Site_number",
"data": [{
"type": "combine",
"linkType": "multi",
"link": "Site_number",
"measure": "VALUE_VALEUR",
"values": "VARIABLE_NAME",
"date": "DATE",
"label": {
"type": "config",
"values": "",
"split": ""
},
"regex": "\\(|\\),\\(|\\)",
"split": ",",
"prefix": "",
"suffix": "MG/L"
}],
"details": {
"enabled": true,
"value": "## What a nice pie chart\n**Useful data listed below**\n"
}
}
}]
},
"swiper": {
"enable": false,
Expand All @@ -1025,7 +1058,7 @@
]
},
"draw": {
"enable": true,
"enable": false,
"open": false,
"tools": [
"picker",
Expand Down
4 changes: 1 addition & 3 deletions src/content/samples/frame-extent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@

<script type="text/javascript">
// set config name to data-rv-config
// TODO: CORS errors doesn't let us read from the cloud at the moment so use the version on GitHub when developing
document.getElementById('fgpmap').setAttribute('data-rv-config', 'https://viewer-visualiseur-dev.services.geo.ca/fgpv-vpgf/author-auteur/config/' + localStorage.getItem('configextent') + '.json');
//document.getElementById('fgpmap').setAttribute('data-rv-config', 'https://raw.githubusercontent.com/fgpv-vpgf/fgpa-apgf/develop/src/content/samples/config/' + localStorage.getItem('configextent') + '.json');
document.getElementById('fgpmap').setAttribute('data-rv-config', './config/' + localStorage.getItem('configextent') + '.json');
localStorage.removeItem('configextent');
</script>

Expand Down
26 changes: 12 additions & 14 deletions src/content/samples/frame-preview.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
<meta content="width=device-width,initial-scale=1" name="viewport">
<script>
var version = localStorage.getItem('viewerversion');
var envar = localStorage.getItem('viewerenv');
envar = (envar === 'dev') ? 'dev.' : 'dev'; // TODO: modify when we have cloud in prod
// set css path for viewer
var styles = document.createElement('link');
styles.rel = 'stylesheet';
styles.type = 'text/css';
styles.href = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/rv-styles.css'.replace('x.x.x', version).replace('{env}', envar);
styles.href = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/rv-styles.css'.replace('x.x.x', version);
document.getElementsByTagName('head')[0].appendChild(styles);
// set plugins js and css
Expand All @@ -39,14 +37,12 @@
// RAMP core plugins are not at the same as custom plugins
var path = '';
if (plugins[i] === 'coordInfo') {
addScriptTag('https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/core-plugins/ramp-plugin-coordinate-info.js'.replace('x.x.x', version).replace('{env}', envar));
addScriptTag('https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/core-plugins/ramp-plugin-coordinate-info.js'.replace('x.x.x', version));
} else if (plugins[i] === 'areasOfInterest') {
addScriptTag('https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/core-plugins/ramp-plugin-areas-of-interest.js'.replace('x.x.x', version).replace('{env}', envar));
addScriptTag('https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/core-plugins/ramp-plugin-areas-of-interest.js'.replace('x.x.x', version));
} else {
// TODO: use version on the cloud when we will have dev and prod
// path = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/core-plugins/'.replace('x.x.x', version).replace('{env}', envar)
// + pluginDash + '/' + pluginDash;
path = 'https://jolevesq.github.io/contributed-plugins/' + pluginDash + '/' + pluginDash;
// TODO: remove version number from plugins name (Prod use prod version and dev use by dev version)
path = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/contributed-plugins/' + pluginDash + '/' + pluginDash;
addScriptTag(path + '.js');
addStyleTag(path + '.css');
}
Expand Down Expand Up @@ -86,18 +82,20 @@
// set viewer array of plugin
document.getElementById('fgpmap').setAttribute('rv-plugins', localStorage.getItem('configplugins'));
// set viewer version
// set viewer version (rv-main and rv-legacy)
var scriptTag = document.createElement('script');
var scriptTagLegacy = document.createElement('script');
var version = localStorage.getItem('viewerversion');
var envar = localStorage.getItem('viewerenv');
envar = (envar === 'dev') ? 'dev.' : 'dev'; // TODO: modify when we have cloud in prod
scriptTag.src = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/rv-main.js'.replace('x.x.x', version).replace('{env}', envar);
scriptTag.src = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/rv-main.js'.replace('x.x.x', version);
scriptTagLegacy.src = 'https://viewer-visualiseur-dev.services.geo.ca/apps/RAMP/fgpv/fgpv-x.x.x/legacy-api.js'.replace('x.x.x', version);
document.body.appendChild(scriptTagLegacy);
document.body.appendChild(scriptTag);
// remove local storage items
localStorage.removeItem('configlangs');
localStorage.removeItem('configpreview');
localStorage.removeItem('configplugins');
localStorage.removeItem('viewerversion');
localStorage.removeItem('viewerenv');
</script>

</body>
Expand Down
Loading

0 comments on commit 5242e69

Please sign in to comment.