Skip to content

Commit

Permalink
Code formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicagood committed Nov 26, 2018
1 parent 6c09a2f commit e6a2dd3
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 223 deletions.
1 change: 1 addition & 0 deletions www/app/maps/map/map.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
vm.isWeb = IS_WEB;
vm.newNestModal = {};
vm.newNestProperties = {};
vm.popover = {};
vm.saveEditsText = 'Save Edits';
vm.showSaveEditsBtn = false;

Expand Down
207 changes: 112 additions & 95 deletions www/app/maps/offline-maps/archive-tiles.controller.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions www/app/maps/offline-maps/offline-map.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@
function goToMap(map) {
$ionicLoading.show({
'template': '<ion-spinner></ion-spinner>'
}).then(function(){
}).then(function () {
OfflineTilesFactory.getMapCenterTile(map.mapid).then(function (centerTile) {
$log.log('gotcenterTile: ', centerTile);
if(centerTile) {
if (centerTile) {
var parts = centerTile.split('_');
var z = Number(parts[0]);
var x = Number(parts[1]);
Expand All @@ -150,13 +150,13 @@
MapViewFactory.zoomToPoint([lng, lat], z);
$location.path('/app/map');
}
},function(err){ //map not found
$log.log('Found Error: ',err);
}, function (err) { //map not found
$log.log('Found Error: ', err);
$ionicLoading.hide();
$ionicPopup.alert({
'title': 'Error!',
'template': 'Offline map not found on device.<br>(code: '+err+')'
}).then(function(){
'template': 'Offline map not found on device.<br>(code: ' + err + ')'
}).then(function () {
$ionicLoading.hide();
});
});
Expand Down
22 changes: 12 additions & 10 deletions www/app/maps/offline-maps/offline-tile.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
.module('app')
.factory('OfflineTilesFactory', OfflineTilesFactory);

OfflineTilesFactory.$inject = ['$cordovaFileTransfer', '$http', '$ionicLoading', '$ionicPopup', '$log', '$q', '$timeout', 'LocalStorageFactory'];
OfflineTilesFactory.$inject = ['$cordovaFileTransfer', '$http', '$ionicLoading', '$ionicPopup', '$log', '$q',
'$timeout', 'LocalStorageFactory'];

// used to determine what the map provider is before we archive a tileset
function OfflineTilesFactory($cordovaFileTransfer, $http, $ionicLoading, $ionicPopup, $log, $q, $timeout, LocalStorageFactory) {
function OfflineTilesFactory($cordovaFileTransfer, $http, $ionicLoading, $ionicPopup, $log, $q, $timeout,
LocalStorageFactory) {
var downloadErrors = 0;
var offlineMaps = [];

Expand Down Expand Up @@ -69,7 +71,7 @@
$ionicPopup.alert({
'title': 'Append Error!',
'template': 'Cannot append the selected new tiles to the saved map <b>' + map.name + '</b> since the map' +
' tile provider is not the same. A new map name must be given if you wish to use a different tile provider.'
' tile provider is not the same. A new map name must be given if you wish to use a different tile provider.'
});
deferred.reject();
}
Expand All @@ -91,29 +93,29 @@
// deletes all offline tiles
var deferred = $q.defer();
offlineMaps = [];
LocalStorageFactory.clearFiles(maps).then(function(){ //clear tile zips and caches
LocalStorageFactory.clearFiles(maps).then(function () { //clear tile zips and caches
// then delete all map names
LocalStorageFactory.getDb().mapNamesDb.clear(function (err) {
if (err) deferred.reject(err);
else deferred.resolve();
else deferred.resolve();
});
},function(error){
}, function (error) {
deferred.resolve(error);
});
return deferred.promise;
}

function deleteMap(mapToDelete) {
var deferred = $q.defer();
LocalStorageFactory.deleteMapFiles(mapToDelete).then(function() {
LocalStorageFactory.deleteMapFiles(mapToDelete).then(function () {
LocalStorageFactory.getDb().mapNamesDb.removeItem(mapToDelete.name).then(function () {
// Map is deleted, and this is now fully resolved
offlineMaps = _.reject(offlineMaps, function (offlineMap) {
return offlineMap.name === mapToDelete.name;
});
deferred.resolve();
});
},function(){
}, function () {
$log.log('LocalStorageFactory.deleteMapFiles failed to resolve.');
deferred.resolve();
});
Expand Down Expand Up @@ -144,7 +146,7 @@
var deferred = $q.defer();
var totalcount = 0;
LocalStorageFactory.getDb().mapNamesDb.iterate(function (value, key) {
if(value.existCount) {
if (value.existCount) {

totalcount = totalcount + value.existCount;

Expand All @@ -157,7 +159,7 @@

// Read from storage
function read(mapProvider, tile, callback) {
tile=tile.replace(/\//g,'_');
tile = tile.replace(/\//g, '_');
var tileId = tile + '.png';
LocalStorageFactory.getTile(mapProvider, tileId).then(function (blob) {
callback(blob);
Expand Down
2 changes: 1 addition & 1 deletion www/app/maps/offline-maps/slippy-tile-names.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
function lat2tile(lat, zoom) {
return (Math.floor(
(1 - Math.log(Math.tan(lat * Math.PI / 180) + 1 / Math.cos(lat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2,
zoom)));
zoom)));
}

// borrowed from http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames
Expand Down
69 changes: 34 additions & 35 deletions www/app/project/manage/manage-project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

function ManageProjectController($document, $ionicModal, $ionicLoading, $ionicPopover, $ionicPopup, $log, $scope,
$state, $q, $window, FormFactory, ImageFactory, LiveDBFactory, LocalStorageFactory,
OtherMapsFactory, ProjectFactory, RemoteServerFactory,SpotFactory, UserFactory,
OtherMapsFactory, ProjectFactory, RemoteServerFactory, SpotFactory, UserFactory,
IS_WEB) {
var vm = this;

Expand Down Expand Up @@ -223,17 +223,17 @@
outputMessage('NEW Images Downloaded: ' + imagesDownloadedCount + ' of ' + neededImagesIds.length +
'<br>NEW Images Saved: ' + savedImagesCount + ' of ' + neededImagesIds.length);
//return readDataUrl(response.data).then(function (base64Image) {
return ImageFactory.saveImage(response.data, neededImageId).then(function () {
return ImageFactory.saveImage(response.data, neededImageId).then(function () {
//return ImageFactory.saveImage(base64Image, neededImageId).then(function () {
savedImagesCount++;
notifyMessages.pop();
outputMessage(
'NEW Images Downloaded: ' + imagesDownloadedCount + ' of ' + neededImagesIds.length +
'<br>NEW Images Saved: ' + savedImagesCount + ' of ' + neededImagesIds.length);
}, function () {
$log.error('Unable to save image locally', neededImageId);
imagesFailedCount++;
});
savedImagesCount++;
notifyMessages.pop();
outputMessage(
'NEW Images Downloaded: ' + imagesDownloadedCount + ' of ' + neededImagesIds.length +
'<br>NEW Images Saved: ' + savedImagesCount + ' of ' + neededImagesIds.length);
}, function () {
$log.error('Unable to save image locally', neededImageId);
imagesFailedCount++;
});
//});
}
else {
Expand Down Expand Up @@ -464,7 +464,7 @@
}).finally(function () {
$ionicLoading.show({
scope: $scope, template: notifyMessages.join('<br>') + '<br><br>' +
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
});
});
}, function () {
Expand Down Expand Up @@ -609,11 +609,11 @@
$log.log('Finished updating dataset', dataset, '. Response:', response);
return RemoteServerFactory.addDatasetToProject(project.id, dataset.id, UserFactory.getUser().encoded_login)
.then(function (response2) {
$log.log('Finished adding dataset to project', project, '. Response:', response2);
return uploadSpots(dataset).then(function () {
deferred.resolve();
});
},
$log.log('Finished adding dataset to project', project, '. Response:', response2);
return uploadSpots(dataset).then(function () {
deferred.resolve();
});
},
function (err) {
uploadErrors = true;
$log.log('Error adding dataset to project. Response:', err);
Expand Down Expand Up @@ -761,7 +761,7 @@
outputMessage('Error updating Spots in dataset' + dataset.name);
if (err && err.data && err.data.Error) $log.error(err.data.Error);
if (err && err.statusText) outputMessage('Server Error: ' + err.statusText);
return $q.when(null);
return $q.when(null);
});
}
}
Expand All @@ -788,7 +788,7 @@
var confirmPopup = $ionicPopup.confirm({
'title': 'Delete Dataset Warning!',
'template': 'Are you sure you want to <span style="color:red">DELETE</span> the Dataset' +
' <b>' + dataset.name + '</b>? This will also delete the Spots in this dataset.',
' <b>' + dataset.name + '</b>? This will also delete the Spots in this dataset.',
'cssClass': 'warning-popup'
});
confirmPopup.then(function (res) {
Expand All @@ -808,7 +808,7 @@
var confirmPopup = $ionicPopup.confirm({
'title': 'Delete Project Warning!',
'template': 'Are you sure you want to <span style="color:red">DELETE</span> the project' +
' <b>' + project.name + '</b>. This will also delete all datasets and Spots contained within the project.',
' <b>' + project.name + '</b>. This will also delete all datasets and Spots contained within the project.',
'cssClass': 'warning-popup'
});
confirmPopup.then(function (res) {
Expand Down Expand Up @@ -859,14 +859,14 @@
$ionicPopup.alert({
'title': 'Type in Use',
'template': 'This type is used in the following Spot. Please remove the type from this Spot before' +
' deleting this type. Spot: ' + spotNames.join(', ')
' deleting this type. Spot: ' + spotNames.join(', ')
});
}
else if (usedType.length > 1) {
$ionicPopup.alert({
'title': 'Type in Use',
'template': 'This type is used in the following Spots. Please remove the type from these Spots before' +
' deleting this type. Spots: ' + spotNames.join(', ')
' deleting this type. Spots: ' + spotNames.join(', ')
});
}
else {
Expand Down Expand Up @@ -917,11 +917,11 @@
}
}*/

function exportProject() {
vm.popover.hide().then(function () {
exportData();
});
}
function exportProject() {
vm.popover.hide().then(function () {
exportData();
});
}

function oldexportProject() {
vm.popover.hide().then(function () {
Expand Down Expand Up @@ -994,7 +994,6 @@
}



function oldimportProject() {
vm.popover.hide().then(function () {
vm.importItem = undefined;
Expand Down Expand Up @@ -1093,7 +1092,7 @@
}).finally(function () {
$ionicLoading.show({
scope: $scope, template: notifyMessages.join('<br>') + '<br><br>' +
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
});
});
}
Expand Down Expand Up @@ -1138,7 +1137,7 @@
}).finally(function () {
$ionicLoading.show({
scope: $scope, template: notifyMessages.join('<br>') + '<br><br>' +
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
'<a class="button button-clear button-outline button-light" ng-click="vm.hideLoading()">OK</a>'
});
});
}
Expand Down Expand Up @@ -1207,9 +1206,9 @@
var confirmPopup = $ionicPopup.confirm({
'title': 'Delete Local Project Warning!',
'template': 'Switching projects will <span style="color:red">DELETE</span> the local copy of the' +
' current project <b>' + vm.project.description.project_name + '</b> including all datasets and Spots' +
' contained within this project. Make sure you have already uploaded the project to the server if you' +
' wish to preserve the data. Continue?',
' current project <b>' + vm.project.description.project_name + '</b> including all datasets and Spots' +
' contained within this project. Make sure you have already uploaded the project to the server if you' +
' wish to preserve the data. Continue?',
'cssClass': 'warning-popup'
});
confirmPopup.then(function (res) {
Expand Down Expand Up @@ -1299,11 +1298,11 @@
else {
vm.activeDatasets.push(datasetToggled);
if (_.isEmpty(ProjectFactory.getSpotIds()[datasetToggled.id]) &&
!_.isEmpty(UserFactory.getUser()) && navigator.onLine) {
!_.isEmpty(UserFactory.getUser()) && navigator.onLine) {
initializeDownloadDataset(datasetToggled);
}
else if (_.isEmpty(ProjectFactory.getSpotIds()[datasetToggled.id]) &&
!_.isEmpty(UserFactory.getUser()) && !navigator.onLine) {
!_.isEmpty(UserFactory.getUser()) && !navigator.onLine) {
$ionicPopup.alert({
'title': 'Cannot Update Dataset!',
'template': 'Unable to reach the server to check if there are already Spots in this dataset to download.'
Expand Down
Loading

0 comments on commit e6a2dd3

Please sign in to comment.