Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmackay committed Sep 5, 2017
2 parents db6503e + 7af6988 commit db57026
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ vault.txt
*.svg
server/www/img/icons/
server/www/
app/locales/
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ COPY . ./
RUN gulp build

FROM nginx

ARG HTTP_PORT=8080

WORKDIR /usr/share/nginx/html
COPY --from=0 /var/app/server/www/ /usr/share/nginx/html
COPY docker/nginx.default.conf /etc/nginx/conf.d/default.conf
COPY docker/nginx.run.sh /nginx.run.sh
RUN sed -i 's/$HTTP_PORT/'$HTTP_PORT'/' /etc/nginx/conf.d/default.conf && \
mkdir /var/lib/nginx && \
chgrp -R 0 . /var/lib/nginx /run && \
chmod -R g+rwX . /var/lib/nginx /run && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log

ENV HTTP_PORT=$HTTP_PORT
EXPOSE $HTTP_PORT

ENTRYPOINT [ "/bin/sh", "/nginx.run.sh" ]
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]
4 changes: 3 additions & 1 deletion app/common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1085,11 +1085,13 @@
"edit_form_success" : "Survey {{name}} updated",
"edit_stage_success" : "Survey task {{name}} updated",
"delete_form_confirm" : "Are you sure you want to delete this survey?",
"delete_form_confirm_desc" : "This action cannot be undone. Deleting this survey will remove all of its data, including posts.",
"destroy_form_success" : "Survey {{name}} deleted",
"delete_stage_confirm" : "Are you sure you want to delete this task?",
"delete_stage_confirm_desc" : "This action cannot be undone. Deleting this task will remove all of its fields, and any data in them.",
"destroy_stage_success" : "Survey task {{name}} deleted",
"delete_attribute_confirm" : "Are you sure you want to delete this field?",
"delete_attribute_confirm_desc" : "Deleting this field will remove its data from all existing posts. Please proceed with caution.",
"delete_attribute_confirm_desc" : "This action cannot be undone. Deleting this field will remove its data from all existing posts.",
"destroy_attribute_success" : "Field {{name}} deleted"
},
"collection" : {
Expand Down
13 changes: 3 additions & 10 deletions app/main/posts/detail/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ <h1 class="form-sheet-title survey-title">
ng-if="form_attributes[key].type === 'media'"
label="{{form_attributes[key].label}}"
media-id="value"></post-media-value>

<div ng-if="form_attributes[key].input === 'tags'">
<h2 class="form-label">{{form_attributes[key].label}}</h2>
<svg class="iconic" style="margin-right:4px;">
<use xlink:href="/img/iconic-sprite.svg#tag"></use>
</svg>
{{formatTags(post.values[key])}}
</span>
</div>
</div>
<div
ng-if="post.content"
Expand All @@ -71,10 +62,11 @@ <h2 class="form-label">{{form_attributes[key].label}}</h2>

<post-value
ng-repeat="(key,value) in post.values"
ng-if="form_attributes[key].type !== 'media' && isPostValue(key) && showType(form_attributes[key].type) && form_attributes[key].input !== 'tags'"
ng-if="form_attributes[key].type !== 'media' && isPostValue(key) && showType(form_attributes[key].type)"
key="key"
value="value"
attribute="form_attributes[key]"
tags="tags"
type="'post'">
</post-value>
<post-detail-map post-id="post.id"></post-detail-map>
Expand Down Expand Up @@ -120,6 +112,7 @@ <h3 class="listing-heading" translate="app.tasks">Tasks</h3>
ng-show="form_attributes[key].form_stage_id === visibleTask"
>
<post-value
tags="tags"
key="key"
value="value"
attribute="form_attributes[key]"
Expand Down
17 changes: 1 addition & 16 deletions app/main/posts/detail/post-detail.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,22 +159,7 @@ function (
return $scope.form_attributes[key] && $scope.post_task &&
$scope.form_attributes[key].form_stage_id === $scope.post_task.id;
};
$scope.formatTags = function (tagIds) {
// getting tag-names and formatting them for displaying
var formatedTags = ' ';
_.each(tagIds, function (tag, index) {
var tagObj = _.where($scope.tags, {id: parseInt(tag)});
if (tagObj[0]) {
tag = tagObj[0].tag;
if (index < tagIds.length - 1) {
formatedTags += tag + ', ';
} else {
formatedTags += tag;
}
}
});
return formatedTags;
};

$scope.showType = function (type) {
if (type === 'point') {
return false;
Expand Down
26 changes: 24 additions & 2 deletions app/main/posts/detail/post-value.directive.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
module.exports = ['PostEndpoint', 'moment', function (PostEndpoint, moment) {
module.exports = ['PostEndpoint', 'moment', '_', function (PostEndpoint, moment, _) {
return {
restrict: 'E',
replace: true,
scope: {
key: '=',
value: '=',
attribute: '=',
type: '='
type: '=',
tags: '='
},
template: require('./post-value.html'),
link: function ($scope) {
// This whole directive is wrong and it should feel wrong
// Depending on whether we are dealing with a post task or a standard task
// the css class is swapped. This Boolean manages that distinction.
$scope.standardTask = $scope.type === 'standard';
// TODO Move to Service
$scope.formatTags = function (tagIds) {
// getting tag-names and formatting them for displaying
var formatedTags = ' ';
_.each(tagIds, function (tag, index) {
var tagObj = _.where($scope.tags, {id: parseInt(tag)});
if (tagObj[0]) {
tag = tagObj[0].tag;
if (index < tagIds.length - 1) {
formatedTags += tag + ', ';
} else {
formatedTags += tag;
}
}
});
return formatedTags;
};
if ($scope.attribute.type === 'relation') {
$scope.value = $scope.value.map(function (entry) {
return PostEndpoint.get({ id : entry });
});
}
if ($scope.attribute.input === 'tags') {
$scope.value = $scope.formatTags($scope.value);
}
if ($scope.attribute.type === 'datetime') {
if ($scope.attribute.input === 'date') {
$scope.value = $scope.value.map(function (entry) {
Expand Down
13 changes: 12 additions & 1 deletion app/main/posts/detail/post-value.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
<div ng-class="{'postcard-field': !standardTask, 'listing-item-primary': standardTask}">

<div ng-if="attribute.input !== 'video'">
<h2 class="form-label">
{{attribute.label}}
</h2>

<div ng-if="attribute.input === 'tags'">
<p>
<svg class="iconic" style="margin-right:4px;">
<use xlink:href="/img/iconic-sprite.svg#tag"></use>
</svg>
{{value}}
</p>
</div>


<div ng-repeat="entry in value" ng-if="attribute.type === 'relation'">
<a ng-href="/posts/{{entry.id}}">{{entry.title}}</a>
</div>
<div ng-repeat="entry in value" ng-if="attribute.type !== 'relation'">
<div ng-repeat="entry in value" ng-if="attribute.type !== 'relation' && attribute.input !== 'tags'">
<p ng-if="attribute.type !== 'markdown'">{{entry}}</p>
<p ng-if="attribute.type === 'markdown'" markdown-to-html="entry"></p>
</div>
Expand Down
12 changes: 3 additions & 9 deletions app/main/posts/views/filters/filter-posts.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ function FilterPostsDirective() {
};
}

FilterPostsController.$inject = ['$scope', '$timeout','ModalService'];
function FilterPostsController($scope, $timeout, ModalService) {
FilterPostsController.$inject = ['$scope', '$timeout','ModalService', 'PostFilters'];
function FilterPostsController($scope, $timeout, ModalService, PostFilters) {
$scope.searchSavedToggle = false;
$scope.cancel = cancel;
$scope.applyFilters = applyFilters;
Expand Down Expand Up @@ -50,12 +50,6 @@ function FilterPostsController($scope, $timeout, ModalService) {
}

function rollbackForm() {
// Store value of q
var q = $scope.postFiltersForm.q.$viewValue;
// Rolback form
$scope.postFiltersForm.$rollbackViewValue();
// Restore value of q
$scope.postFiltersForm.q.$setViewValue(q);
$scope.postFiltersForm.q.$render();
PostFilters.clearFilters();
}
}
2 changes: 1 addition & 1 deletion app/settings/surveys/survey-editor.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ function SurveyEditorController(

function deleteTask(task) {

Notify.confirmDelete('notify.form.delete_stage_confirm').then(function () {
Notify.confirmDelete('notify.form.delete_stage_confirm', 'notify.form.delete_stage_confirm_desc').then(function () {
// If we haven't saved the task yet then we can just drop it
if (!task.id || _.isString(task.id)) {
$scope.survey.tasks = _.filter($scope.survey.tasks, function (item) {
Expand Down
3 changes: 1 addition & 2 deletions app/settings/surveys/surveys.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ function (
};

$scope.deleteSurvey = function (survey) {
Notify.confirmDelete('notify.form.delete_form_confirm').then(function () {

Notify.confirmDelete('notify.form.delete_form_confirm', 'notify.form.delete_form_confirm_desc').then(function () {
// If we haven't saved the survey
// just go back to the surveys views
if (!survey.id) {
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx.default.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server {

listen 80 default_server;
listen $HTTP_PORT default_server;
server_name _;

root /usr/share/nginx/html;
Expand Down
10 changes: 10 additions & 0 deletions single.stage.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ushahidi/node-ci:node-6

ARG HTTP_PORT=8080

RUN apt-get update && \
apt-get install -y nginx && \
apt-get clean && \
Expand All @@ -17,6 +19,14 @@ WORKDIR /usr/share/nginx/html
RUN rsync -a --delete-after /var/app/server/www/ /usr/share/nginx/html/
COPY docker/nginx.default.conf /etc/nginx/sites-enabled/default
COPY docker/nginx.run.sh /nginx.run.sh
RUN sed -i 's/$HTTP_PORT/'$HTTP_PORT'/' /etc/nginx/sites-enabled/default && \
chgrp -R 0 . /var/lib/nginx /run && \
chmod -R g+rwX . /var/lib/nginx /run && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log

ENV HTTP_PORT=$HTTP_PORT
EXPOSE $HTTP_PORT

ENTRYPOINT [ "/bin/sh", "/nginx.run.sh" ]
CMD [ "/usr/sbin/nginx", "-g", "daemon off;" ]

0 comments on commit db57026

Please sign in to comment.