Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Dec 3, 2018
2 parents 9855ff4 + 856e3ab commit a8e94d7
Show file tree
Hide file tree
Showing 113 changed files with 2,078 additions and 609 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ node_modules
*.sassc

#custom
package-lock.json
config.json
import.csv
/src/mailer/templates/promo/
Expand All @@ -53,3 +54,5 @@ public/css/app.css
*.local
sonar-project.properties
.scannerwork/

public/uploads/assets/*.*
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ function dbCallback(err, db) {
function(next) {
require('./src/settings/defaults').init(next);
},
function(next) {
winston.debug('Building dynamic sass...');
require('./src/sass/buildsass').build(next);
},
function(next) {
//Start Task Runners
require('./src/taskrunner');
Expand Down
5 changes: 2 additions & 3 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ module.exports = function(grunt) {
'public/css/plugins/datatables/dataTables.scroller.css',
'public/css/plugins/datatables/dataTables.foundation.css',
'src/public/js/vendor/chosen/chosen.css',
'src/public/js/vendor/pace/pace.theme.css',
'src/public/js/vendor/enjoyhint/enjoyhint.css',
'src/public/js/vendor/metricsgraphics/metricsgraphics.css',
'public/css/vendor/font-awesome.min.css',
Expand Down Expand Up @@ -133,8 +132,8 @@ module.exports = function(grunt) {
});

grunt.registerTask('buildcss', ['uglify:uikit', 'cssmin']);
grunt.registerTask('server', 'launch webserver and watch tasks', ['parallel:web']);
grunt.registerTask('build', ['buildcss', 'shell:webpackDist']);
grunt.registerTask('server', 'launch webserver and watch tasks', ['uglify:uikit', 'cssmin', 'parallel:web']);
grunt.registerTask('build', ['uglify:uikit', 'cssmin', 'shell:webpackDist']);
grunt.registerTask('devbuild', ['shell:webpackDev']);
grunt.registerTask('default', ['server']);
};
4 changes: 4 additions & 0 deletions mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

<script src="lib/ngstorage/ngStorage.min.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<!-- <script src="cordova.js"></script> -->

<!--ionic filter plugin-->
<link rel="stylesheet" href="lib/ionic-filter-bar/dist/ionic.filter.bar.css">
<script src="lib/ionic-filter-bar/dist/ionic.filter.bar.js" charset="utf-8"></script>
Expand All @@ -39,6 +42,7 @@
<script src="lib/Autolinker.js/dist/Autolinker.min.js" charset="utf-8"></script>
<script src="lib/moment/min/moment.min.js" charset="utf-8"></script>
<script src="lib/angular-moment/angular-moment.min.js" charset="utf-8"></script>
<script src="lib/angular-img-http-src/index.js" charset="utf-8"></script>

<!-- your app's js -->
<script src="js/dist/td.app.min.js"></script>
Expand Down
40 changes: 35 additions & 5 deletions mobile/js/dist/td.app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,17 @@ angular.module('trudesk', [
'ngCropper',
'monospaced.elastic',
'angularMoment',
'jett.ionic.filter.bar'
'jett.ionic.filter.bar',
'angular.img'
])

.run(function($ionicPlatform, $rootScope, $location, $localStorage, $state) {
.run(function($ionicPlatform, $rootScope, $location, $localStorage, $state, $http) {
if ($localStorage.accessToken) {
$http.defaults.headers.common.accesstoken = $localStorage.accessToken;
} else {
$http.defaults.headers.common.accesstoken = '';
}

$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
Expand Down Expand Up @@ -71,7 +78,7 @@ angular.module('trudesk', [
}
});

setTimeout(function() {
setTimeout(function() {
angular.element(document.querySelector('#loader')).addClass('hide');
}, 900);
});
Expand Down Expand Up @@ -291,7 +298,6 @@ angularPeity.directive('lineChart', function() {
return peityDirective('line');
});


var fileOnChange = angular.module('fileOnChange', []);

fileOnChange.directive('fileOnChange', function() {
Expand Down Expand Up @@ -353,7 +359,7 @@ hideTabBar.directive('hideTabBar', function($timeout) {
restrict: 'A',
compile: function(element, attr) {
var tabBar = document.querySelector('.tab-nav');
console.log(tabBar);

return function($scope, $element, $attr) {
var scroll = $element[0].querySelector('.scroll-content');
$scope.$on('$ionicView.beforeEnter', function() {
Expand Down Expand Up @@ -725,6 +731,19 @@ angular.module('trudesk.services', [])
})
.factory('Users', function($q, $http, $localStorage) {
return {
getImage: function(url) {
return new Promise(function(resolve, reject) {
$http.get(url, {
method: 'GET',
headers: {
'accesstoken': $localStorage.accessToken
}
}).then(function(response) {
var objectUrl = URL.createObjectURL(response.blob());
return resolve(objectUrl);
}).catch(function(err) { return reject(err); });
});
},
get: function(username) {
return $http.get('/api/v1/users/' + username, {
headers: {
Expand Down Expand Up @@ -1132,6 +1151,8 @@ angular.module('trudesk.controllers.login', []).controller('LoginCtrl', function
$localStorage.accessToken = response.data.accessToken;
$localStorage.loggedInUser = response.data.user;

$http.defaults.headers.common.accesstoken = $localStorage.accessToken;

//OneSignal
if (window.plugins && window.plugins.OneSignal) {
window.plugins.OneSignal.setSubscription(true);
Expand Down Expand Up @@ -1276,6 +1297,7 @@ angular.module('trudesk.controllers.accounts', [])
ionic.trigger('$trudesk.clearLoginForm', {});
$localStorage.server = undefined;
$localStorage.accessToken = undefined;
$http.defaults.headers.common.accesstoken = $localStorage.accessToken;
if (window.plugins && window.plugins.OneSignal)
window.plugins.OneSignal.setSubscription(false);
$ionicHistory.clearCache();
Expand Down Expand Up @@ -2450,6 +2472,14 @@ angular.module('trudesk.controllers.tickets', []).controller('TicketsCtrl', func
});
};

$scope.getUserImage = function(imageFile) {
var url = 'http://' + $localStorage.server + '/uploads/users/' + imageFile;

return Users.getImage(url).then(function(image) {
console.log(image);
});
}

$scope.fetchTickets = function() {
angular.element(document).find('ion-item').removeClass('item-remove-animate');
if ($scope.page == undefined)
Expand Down
4 changes: 2 additions & 2 deletions mobile/js/dist/td.app.min.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions mobile/lib/angular-img-http-src/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "angular-img-http-src",
"version": "1.0.1",
"authors": [
"Doug Moscrop <[email protected]>"
],
"description": "Fetch images via $http and set src to a Blob URL",
"main": "index.js",
"moduleType": [
"globals"
],
"keywords": [
"angular",
"img",
"http",
"token-based-auth"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "1.x"
},
"homepage": "https://github.com/dmoscrop/angular-img-http-src",
"_release": "1.0.1",
"_resolution": {
"type": "version",
"tag": "v1.0.1",
"commit": "3835b5b271134daeeab0d323f792d0a1560eab87"
},
"_source": "https://github.com/dmoscrop/angular-img-http-src.git",
"_target": "^1.0.1",
"_originalSource": "angular-img-http-src",
"_direct": true
}
22 changes: 22 additions & 0 deletions mobile/lib/angular-img-http-src/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2014 Doug Moscrop

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8 changes: 8 additions & 0 deletions mobile/lib/angular-img-http-src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# angular-img-http-src
Status: Go horse.

## Problem
You used token based auth and you need to serve images from secured routes.

## Solution
Use `http-src` instead of `ng-src` and it will fetch images using the `$http` service - meaning Authorization headers added via interceptors will be present - then build a `Blob` and set the `src` to an [objectURL](https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL).
29 changes: 29 additions & 0 deletions mobile/lib/angular-img-http-src/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "angular-img-http-src",
"version": "1.0.1",
"authors": [
"Doug Moscrop <[email protected]>"
],
"description": "Fetch images via $http and set src to a Blob URL",
"main": "index.js",
"moduleType": [
"globals"
],
"keywords": [
"angular",
"img",
"http",
"token-based-auth"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"angular": "1.x"
}
}
42 changes: 42 additions & 0 deletions mobile/lib/angular-img-http-src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(function () {
'use strict';
/*global angular, Blob, URL */

angular.module('angular.img', [
]).directive('httpSrc', ['$http', function ($http) {
return {
link: function ($scope, elem, attrs) {
function revokeObjectURL() {
if ($scope.objectURL) {
URL.revokeObjectURL($scope.objectURL);
}
}

$scope.$watch('objectURL', function (objectURL) {
elem.attr('src', objectURL);
});

$scope.$on('$destroy', function () {
revokeObjectURL();
});

attrs.$observe('httpSrc', function (url) {
revokeObjectURL();

if(url && url.indexOf('data:') === 0) {
$scope.objectURL = url;
} else if(url) {
$http.get(url, { responseType: 'arraybuffer' })
.then(function (response) {
var blob = new Blob(
[ response.data ],
{ type: response.headers('Content-Type') }
);
$scope.objectURL = URL.createObjectURL(blob);
});
}
});
}
};
}]);
}());
25 changes: 25 additions & 0 deletions mobile/lib/angular-img-http-src/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "angular-img-http-src",
"version": "1.0.1",
"description": "Use $http service to fetch img src as objectURL",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dougmoscrop/angular-img-http-src.git"
},
"keywords": [
"Angular"
],
"author": "Doug Moscrop <[email protected]>",
"license": "MIT",
"bugs": {
"url": "https://github.com/dougmoscrop/angular-img-http-src/issues"
},
"homepage": "https://github.com/dougmoscrop/angular-img-http-src#readme",
"peerDependencies": {
"angular": "1.x"
}
}
11 changes: 10 additions & 1 deletion mobile/lib/ionic/js/ionic-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -2660,9 +2660,18 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl
}

return $timeout(function() {
if (!modalStack.length) {
var otherSibling = false;
for (var i = 0; i < modalStack.length; ++i) {
if (modalStack[i].viewType === self.viewType) {
// there are other modal (or popover, depending on viewType)
otherSibling = true;
break;
}
}
if (!otherSibling) {
$ionicBody.removeClass(self.viewType + '-open');
}

self.el.classList.add('hide');
}, self.hideDelay || 320);
},
Expand Down
10 changes: 9 additions & 1 deletion mobile/lib/ionic/js/ionic.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -55843,7 +55843,15 @@ function($rootScope, $ionicBody, $compile, $timeout, $ionicPlatform, $ionicTempl
}

return $timeout(function() {
if (!modalStack.length) {
var otherSibling = false;
for (var i = 0; i < modalStack.length; ++i) {
if (modalStack[i].viewType === self.viewType) {
// there are other modal (or popover, depending on viewType)
otherSibling = true;
break;
}
}
if (!otherSibling) {
$ionicBody.removeClass(self.viewType + '-open');
}
self.el.classList.add('hide');
Expand Down
Loading

0 comments on commit a8e94d7

Please sign in to comment.