Skip to content

Commit 5c64c1a

Browse files
committed
Merge branch 'master' of github.com:DREAM-ODA-OS/ODAClient
2 parents dc0a626 + af80f1f commit 5c64c1a

File tree

9 files changed

+213
-21
lines changed

9 files changed

+213
-21
lines changed

app/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@
133133
{
134134
"name": "viewContent",
135135
"class": ""
136+
},
137+
{
138+
"name": "info",
139+
"class": ""
136140
}
137141
],
138142

app/data.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,26 @@
216216
"info": {
217217
"id": "MERIS_FRS_L1_ALL_view_outlines"
218218
}
219-
}
219+
},
220+
{
221+
"name": "SPOT 4",
222+
"visible": false,
223+
"timeSlider": true,
224+
"timeSliderProtocol": "WPS",
225+
"view": {
226+
"id": "SPOT4_View",
227+
"protocol": "WMS",
228+
"urls": [
229+
"https://demo.v-manip.eox.at/browse/ows"
230+
],
231+
"style": "default"
232+
},
233+
"download": {
234+
"id": "SPOT4_View",
235+
"protocol": "EOWCS",
236+
"url": "https://demo.v-manip.eox.at/unsec/ows"
237+
}
238+
}
220239
]
221240

222241
}

app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<div id="rightSideBar"></div>
7171
<div id="topBar"></div>
7272
<div id="bottomBar"></div>
73+
<div id="info"></div>
7374
</div>
7475

7576
<div id="loadscreen" class="modal-backdrop"> <i class="fa fa-cog fa-spin fa-4x"></i> </div>

app/scripts/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@
247247
});
248248

249249
$(document).ajaxError(function( event, request, settings ) {
250+
if(settings.suppressErrors) {
251+
return;
252+
}
253+
250254
var statuscode = "";
251255
if (request.status != 0)
252256
statuscode = '<br>Status Code: '+ request.status;

app/scripts/models/AuthModel.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
(function() {
3+
'use strict';
4+
var root = this;
5+
root.define(['backbone','communicator'],
6+
function( Backbone, Communicator ) {
7+
var AuthModel = Backbone.Model.extend({
8+
url: ''
9+
});
10+
return {'AuthModel':AuthModel};
11+
});
12+
}).call( this );

app/scripts/views/AuthView.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
(function() {
2+
'use strict';
3+
4+
5+
var root = this;
6+
root.define([
7+
'backbone',
8+
'communicator',
9+
'globals',
10+
'hbs!tmpl/iFrame',
11+
'underscore'
12+
],
13+
function( Backbone, Communicator, globals, iFrameTmpl) {
14+
15+
var AuthView = Backbone.Marionette.ItemView.extend({
16+
17+
className: "panel panel-default authview not-selectable",
18+
19+
/*events: {
20+
"load": "onLoadiFrame",
21+
},*/
22+
23+
initialize: function(options) {
24+
this.layerprop = options.layerprop;
25+
},
26+
onShow: function(view){
27+
28+
this.$('.close').on("click", _.bind(this.onClose, this));
29+
this.$el.draggable({
30+
containment: "#content",
31+
scroll: false,
32+
handle: '.panel-heading'
33+
});
34+
35+
//this.loadcounter = 0;
36+
37+
$('#authiframe').load(function(){
38+
39+
var layer = globals.products.find(function(model) { return model.get('name') == this.layerprop.name; }.bind(this));
40+
var url = layer.get('view').urls[0]+"?";
41+
layer = layer.get('view').id;
42+
43+
var req = "LAYERS=" + layer + "&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326";
44+
req += "&BBOX=33.75,56.25,33.80,56.50&WIDTH=2&HEIGHT=2";
45+
req = url + req;
46+
47+
var that = this;
48+
49+
$.ajax({
50+
url: req,
51+
type: "GET",
52+
suppressErrors: true,
53+
xhrFields: {
54+
withCredentials: true
55+
},
56+
success: function(xml, textStatus, xhr) {
57+
58+
Communicator.mediator.trigger('map:layer:change', that.layerprop);
59+
that.close();
60+
},
61+
error: function(jqXHR, textStatus, errorThrown) {
62+
if (jqXHR.status == 403){
63+
$("#error-messages").append(
64+
'<div class="alert alert-warning alert-danger">'+
65+
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
66+
'<strong>Warning!</strong> You are not authorized to access this product' +
67+
'</div>'
68+
);
69+
that.close();
70+
}
71+
}
72+
});
73+
74+
}.bind(this));
75+
76+
77+
},
78+
79+
onClose: function() {
80+
81+
this.close();
82+
},
83+
84+
onLoadiFrame: function(){
85+
console.log("iframe loaded");
86+
}
87+
88+
});
89+
return {'AuthView':AuthView};
90+
});
91+
}).call( this );

app/scripts/views/LayerItemView.js

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,15 @@
3131
root.define([
3232
'backbone',
3333
'communicator',
34+
'views/AuthView',
35+
'models/AuthModel',
3436
'globals',
37+
'app',
3538
'hbs!tmpl/BulletLayer',
39+
'hbs!tmpl/iFrame',
3640
'underscore'
3741
],
38-
function( Backbone, Communicator, globals, BulletLayerTmpl) {
42+
function( Backbone, Communicator, av, am, globals, App, BulletLayerTmpl, iFrameTmpl) {
3943
var LayerItemView = Backbone.Marionette.ItemView.extend({
4044
tagName: "li",
4145
events: {
@@ -86,22 +90,58 @@
8690
if (this.model.get('view').isBaseLayer)
8791
isBaseLayer = true;
8892
var options = { name: this.model.get('name'), isBaseLayer: isBaseLayer, visible: evt.target.checked };
89-
90-
var product = globals.products.find(function(model) { return model.get('name') == options.name; });
91-
92-
if (product){
93-
94-
if (options.visible && product.get("view").protocol=="WMS"){
95-
var getmap = "?LAYERS="+product.get("view").id+"&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.0&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326&BBOX=33.75,56.25,39.375,61.875&WIDTH=256&HEIGHT=256&TIME=2014-02-19T00:00:00Z/2014-02-19T00:00:00Z"
96-
$.get(product.get("view").urls[0] + getmap, function (){
97-
Communicator.mediator.trigger('map:layer:change', options);
98-
}, 'text');
99-
} else {
100-
Communicator.mediator.trigger('map:layer:change', options);
101-
}
102-
}else{
103-
Communicator.mediator.trigger('map:layer:change', options);
104-
}
93+
if( !isBaseLayer && evt.target.checked ){
94+
var layer = globals.products.find(function(model) { return model.get('name') == options.name; });
95+
if (layer != -1) {
96+
var url = layer.get('view').urls[0]+"?";
97+
98+
if (url.indexOf('https') > -1){
99+
100+
var layer = layer.get('view').id;
101+
var req = "LAYERS=" + layer + "&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&SRS=EPSG%3A4326";
102+
req += "&BBOX=33.75,56.25,33.80,56.50&WIDTH=2&HEIGHT=2";
103+
req = url + req;
104+
105+
$.ajax({
106+
url: req,
107+
type: "GET",
108+
suppressErrors: true,
109+
xhrFields: {
110+
withCredentials: true
111+
},
112+
success: function(xml, textStatus, xhr) {
113+
Communicator.mediator.trigger('map:layer:change', options);
114+
},
115+
error: function(jqXHR, textStatus, errorThrown) {
116+
if (jqXHR.status == 403){
117+
$("#error-messages").append(
118+
'<div class="alert alert-warning alert-danger">'+
119+
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'+
120+
'<strong>Warning!</strong> You are not authorized to access this product' +
121+
'</div>'
122+
);
123+
}else{
124+
125+
this.authview = new av.AuthView({
126+
model: new am.AuthModel({url:req}),
127+
template: iFrameTmpl,
128+
layerprop: options
129+
});
130+
131+
Communicator.mediator.trigger("progress:change", false);
132+
133+
App.info.show(this.authview);
134+
135+
}
136+
}
137+
});
138+
}else{
139+
Communicator.mediator.trigger('map:layer:change', options);
140+
}
141+
}
142+
} else if (!evt.target.checked){
143+
Communicator.mediator.trigger('map:layer:change', options);
144+
}
105145
},
106146

107147
drop: function(event, index) {

app/styles/main.scss

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,21 @@ html, body {
5959
position: relative;
6060
}
6161

62+
63+
.authview{
64+
width: 50em;
65+
height: 80%;
66+
top: 5em;
67+
left: 50%;
68+
margin: 0 0 0 -25em;
69+
font-size: 1em;
70+
position: absolute;
71+
}
72+
73+
.authview .panel-body{
74+
height: 97%;
75+
}
76+
6277
ul, li {
6378
list-style-type: none;
6479
list-style-position: inside;
@@ -95,15 +110,14 @@ body.wait *, body.wait {
95110
width: 100%;
96111
height: 100%;
97112
position: absolute;
98-
left: 0;
99113
z-index: 5000;
100114
text-align: center;
101115
opacity: 0.8;
102116
}
103117

104118
#loadscreen i {
105-
top: 35%;
106-
position: absolute;
119+
position:relative;
120+
top: calc(50%);
107121
}
108122

109123
div#preload {

app/templates/iFrame.hbs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="panel-heading">
2+
<button type="button" class="close"><i class="fa fa-times-circle"></i></button>
3+
<i class="fa fa-wrench no-label"></i>
4+
</div>
5+
<div class="panel-body">
6+
<iframe id="authiframe" src="{{url}}" style="width:100%;height:100%"></iframe>
7+
</div>

0 commit comments

Comments
 (0)