Skip to content

Commit

Permalink
Merge pull request MaxBo#645 from MaxBo/feature/Frontend
Browse files Browse the repository at this point in the history
Feature/frontend
  • Loading branch information
ChrFr authored Dec 3, 2019
2 parents 4f1b89b + 21e218a commit dbb405e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
1 change: 1 addition & 0 deletions repair/apps/asmfa/serializers/bulkcreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def validate(self, attrs):
file_type=self.input_file_ext.replace('.', ''),
encoding=self.encoding
)
error_mask.add_message(message)
raise ValidationError(
error_mask.messages, url
)
Expand Down
2 changes: 1 addition & 1 deletion repair/apps/utils/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MakeValid(GeoFunc):


class BulkValidationError(Exception):
def __init__(self, message, path=''):
def __init__(self, message='error', path=''):
super().__init__(message)
self.message = message
self.path = path
Expand Down
4 changes: 3 additions & 1 deletion repair/js/views/common/flowsankey.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ var FlowSankeyView = BaseView.extend(
return;
}
function normalize(v){
return Math.log2(1 + v * normFactor);
var normed = Math.log2(1 + Math.abs(v) * normFactor);
if (v < 0) normed *= -1;
return normed;
}
var source = mapNode(origin),
target = (!isStock) ? mapNode(destination) : addStock();
Expand Down
35 changes: 22 additions & 13 deletions repair/js/views/conclusions/flow-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function(_, BaseView, GDSECollection, Muuri){

var indicatorColumns = [];
this.indicators.forEach(function(indicator){
indicatorColumns.push(indicator.id)
indicatorColumns.push(indicator)
var th = document.createElement('th');
th.innerHTML = indicator.get('name');
header.appendChild(th);
Expand All @@ -109,18 +109,21 @@ function(_, BaseView, GDSECollection, Muuri){

this.aims.forEach(function(aim){
var row = table.insertRow(-1),
desc = aim.get('description') || '';
var panelItem = _this.panelItem(aim.get('text'), {
popoverText: desc.replace(/\n/g, "<br/>")
desc = aim.get('description') || '',
title = aim.get('text');
var panelItem = _this.panelItem(title, {
popoverText: '<b>' + title + '</b><br>' + desc.replace(/\n/g, "<br/>"),
})
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);
var indicatorCount = _this.indicatorCountPerAim[aim.id];
indicatorColumns.forEach(function(indicatorId){
var count = indicatorCount[indicatorId],
indicatorColumns.forEach(function(indicator){
var count = indicatorCount[indicator.id],
cell = row.insertCell(-1);
if (count){
var item = _this.panelItem(count + ' x');
var item = _this.panelItem(count + ' x', {
popoverText: '<b>' + indicator.get('name') + '</b> ' + gettext('used') + ' ' + count + ' x ' + 'in' + ' <b>' + aim.get('text') + '</b>'
});
item.style.backgroundImage = 'none';
item.style.width = '50px';
cell.appendChild(item);
Expand All @@ -145,7 +148,7 @@ function(_, BaseView, GDSECollection, Muuri){

var userColumns = [];
this.users.forEach(function(user){
userColumns.push(user.id);
userColumns.push(user);
var name = user.get('alias') || user.get('name'),
th = document.createElement('th');
th.innerHTML = name;
Expand All @@ -154,18 +157,24 @@ function(_, BaseView, GDSECollection, Muuri){
this.indicators.forEach(function(indicator){
var row = table.insertRow(-1),
text = indicator.get('name') + ' (' + indicator.get('spatial_reference').toLowerCase() + ')';
var panelItem = _this.panelItem(text)
var panelItem = _this.panelItem(text, {
popoverText: text
})
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);
var userTargets = _this.userTargetsPerIndicator[indicator.id];
if (!userTargets) return;
userColumns.forEach(function(userId){
var target = userTargets[userId],
cell = row.insertCell(-1);
userColumns.forEach(function(user){
var target = userTargets[user.id],
cell = row.insertCell(-1),
name = user.get('alias') || user.get('name');
if (target != null){
var targetValue = _this.targetValues.get(target.get('target_value')),
amount = targetValue.get('number'),
item = _this.panelItem(targetValue.get('text'));
targetText = targetValue.get('text'),
item = _this.panelItem(targetText, {
popoverText: '<b>' + name + '</b><br>' + text + '<br>' + targetText
});
cell.appendChild(item);
var hue = (amount >= 0) ? 90 : 0, // green or red
sat = 100 - 70 * Math.abs(Math.min(amount, 1)),
Expand Down
18 changes: 11 additions & 7 deletions repair/js/views/conclusions/objectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function(_, BaseView, GDSECollection, Muuri){
this.users.forEach(function(user){
var name = user.get('alias') || user.get('name'),
th = document.createElement('th');
userColumns.push(user.id);
userColumns.push(user);
th.innerHTML = name;
header.appendChild(th);
var userObjectives = objectives.filterBy({'user': user.get('user')});
Expand Down Expand Up @@ -122,11 +122,14 @@ function(_, BaseView, GDSECollection, Muuri){
item = _this.createAimItem(aim, i);
row.insertCell(0).appendChild(item);
var aimRank = rankingMap[aim.id];
userColumns.forEach(function(userId){
userColumns.forEach(function(user){
var cell = row.insertCell(-1),
rank = aimRank[userId];
rank = aimRank[user.id],
name = user.get('alias') || user.get('name');
if (rank) {
var item = _this.panelItem('#' + rank);
var item = _this.panelItem('#' + rank, {
popoverText: name + ' ' + gettext('ranked') + ' <b>' + aim.get('text') + '</b> #' + rank
});
item.style.width = '50px';
item.style.backgroundImage = 'none';
cell.appendChild(item);
Expand All @@ -141,10 +144,11 @@ function(_, BaseView, GDSECollection, Muuri){
},

createAimItem: function(aim, rank){
var desc = aim.get('description') || '';
var desc = aim.get('description') || '',
title = aim.get('text');

var panelItem = this.panelItem(aim.get('text'), {
popoverText: desc.replace(/\n/g, "<br/>"),
var panelItem = this.panelItem(title, {
popoverText: '<b>' + title + '</b><br>' + desc.replace(/\n/g, "<br/>"),
overlayText: '#' + rank
})
panelItem.style.maxWidth = '500px';
Expand Down
12 changes: 9 additions & 3 deletions repair/js/views/conclusions/strategies.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
var row = table.insertRow(-1),
text = solution.get('name'),
questions = _this.questions[solution.id];
var solItem = _this.panelItem(text, { overlayText: '0x' });
var solItem = _this.panelItem(text, {
overlayText: '0x',
popoverText: text
});
solItem.style.maxWidth = '600px';
row.insertCell(0).appendChild(solItem);
_this.users.forEach(function(user){
Expand Down Expand Up @@ -452,7 +455,10 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
function addRow(table, node, userSet, totalCount){
var row = table.insertRow(-1),
text = node.get('name');
var panelItem = _this.panelItem(text, { overlayText: totalCount + 'x' });
var panelItem = _this.panelItem(text, {
overlayText: totalCount + 'x',
popoverText: text
});
panelItem.style.width = '500px';
row.insertCell(0).appendChild(panelItem);
_this.users.forEach(function(user){
Expand Down Expand Up @@ -553,7 +559,7 @@ function(_, BaseView, GDSECollection, Map, ol, chroma){
stakeholders.forEach(function(stakeholder){
var row = table.insertRow(-1),
text = stakeholder.get('name');
var panelItem = _this.panelItem(text);
var panelItem = _this.panelItem(text, {popoverText: text});
panelItem.style.maxWidth = '500px';
row.insertCell(0).appendChild(panelItem);

Expand Down
2 changes: 1 addition & 1 deletion repair/js/views/data-entry/bulk-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ var BulkUploadView = BaseView.extend(
dismissible: true
})
alertDiv.querySelector('.close').style.top = '-20px';
_this.log('<p style="color:' + color + ';">' + msg + '</p>')
_this.log('<p style="color:' + color + ';">' + msg + '</p><br>')
_this.loader.deactivate();
_this.refreshStatus();
}
Expand Down

0 comments on commit dbb405e

Please sign in to comment.