Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
* Panorama loading.
* Writing observable with side effects.
* Timeslot picker.
* Exceptions in platform specific tests.
  • Loading branch information
NiHoel committed Jun 20, 2020
1 parent d464a0f commit 91faa8e
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 55 deletions.
133 changes: 82 additions & 51 deletions assets/js/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,27 +331,34 @@ class cordovadirectory extends directory {
}

pathComponents = pathComponents.filter(p => p != null && p != "");
return obs.expand(handle => {
if (!pathComponents.length)
return Rx.Observable.empty();
return obs
.map(handle => [handle, [...pathComponents]])
.expand(elem => {
var handle, pathComponents;
[handle, pathComponents] = elem;

var name = pathComponents.shift();
if (!pathComponents.length)
return Rx.Observable.empty();

if (pathComponents.length || name.indexOf('.') == -1)
var name = pathComponents.shift();

return Rx.Observable.create(obs => {
handle.getDirectory(name, { create: true, exclusive: false },
(entry) => { obs.next(entry); obs.complete(); },
(err) => { obs.error(cordovadirectory.toError(err, path)) });
});
else
return Rx.Observable.create(obs => {
handle.getFile(name, { create: true, exclusive: false },
(entry) => { obs.next(entry); obs.complete(); },
(err) => { obs.error(cordovadirectory.toError(err, path)) }
);
});
}).last();
if (pathComponents.length || name.indexOf('.') == -1)

return Rx.Observable.create(obs => {
handle.getDirectory(name, { create: true, exclusive: false },
(entry) => { obs.next(entry); obs.complete(); },
(err) => { obs.error(cordovadirectory.toError(err, path)) });
}).map(handle => [handle, [...pathComponents]]);
else
return Rx.Observable.create(obs => {
handle.getFile(name, { create: true, exclusive: false },
(entry) => { obs.next(entry); obs.complete(); },
(err) => { obs.error(cordovadirectory.toError(err, path)) }
);
}).map(handle => [handle, [...pathComponents]]);
})
.last()
.map(elem => elem[0]);
}

/**
Expand All @@ -361,7 +368,12 @@ class cordovadirectory extends directory {
*/
searchFile(path) {
return this.searchEntry(path)
.filter(elem => elem instanceof file);
.filter(elem => elem instanceof file)
.defaultIfEmpty(null)
.do(elem => {
if (elem == null)
throw (new error(directory.prototype.ERROR.FILE_NOT_FOUND, "", path));
});
}

/**
Expand All @@ -374,7 +386,12 @@ class cordovadirectory extends directory {
path += '/';

return this.searchEntry(path)
.filter(elem => elem instanceof directory);
.filter(elem => elem instanceof directory)
.defaultIfEmpty(null)
.do(elem => {
if (elem == null)
throw (new error(directory.prototype.ERROR.FILE_NOT_FOUND, "", path));
});
}

/**
Expand Down Expand Up @@ -1812,37 +1829,51 @@ class diskAccessor extends observable {
constructor() {
super();

var browser = platform.name.split(" ")[0];
var mobile = platform.product != null || /Mobile/.test(platform.name);
var version = Number.parseInt(platform.version.split('.')[0]);
var osVersion = Number.parseInt(platform.os.version.split('.')[0]);

this.allowsDrop =
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 4 && !mobile ||
browser == "Chrome" && version >= 4 && !mobile && directory.isRemotePath(window.location.href) ||
browser == "Safari" && version >= 3 && !mobile ||
browser == "Opera" && version >= 12 && !mobile ||
browser == "Safari" && version >= 11 && mobile ||
browser == "IE" && version >= 10 && mobile
;

this.allowsDirectorySelect =
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 58 && !mobile ||
browser == "Chrome" && version >= 49 && !mobile ||
browser == "Safari" && version >= 12 && !mobile
;

this.allowsMultiFileSelect =
browser == "IE" && version >= 11 && !mobile ||
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 58 && !mobile ||
browser == "Chrome" && version >= 49 && !mobile ||
browser == "Safari" && version >= 11 && !mobile ||
browser == "Safari" && version >= 10 && mobile && osVersion >= 5 ||
browser == "Chrome" && version >= 64 && mobile && osVersion >= 5
;
try {

if (platform.name)
var browser = platform.name.split(" ")[0];

var mobile = platform.isMobile;

if(platform.version)
var version = Number.parseInt(platform.version.split('.')[0]);

if (platform.osVersion)
var osVersion = Number.parseInt(platform.os.version.split('.')[0]);

this.allowsDrop =
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 4 && !mobile ||
browser == "Chrome" && version >= 4 && !mobile && directory.isRemotePath(window.location.href) ||
browser == "Safari" && version >= 3 && !mobile ||
browser == "Opera" && version >= 12 && !mobile ||
browser == "Safari" && version >= 11 && mobile ||
browser == "IE" && version >= 10 && mobile
;

this.allowsDirectorySelect =
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 58 && !mobile ||
browser == "Chrome" && version >= 49 && !mobile ||
browser == "Safari" && version >= 12 && !mobile
;

this.allowsMultiFileSelect =
browser == "IE" && version >= 11 && !mobile ||
browser == "Microsoft" && version >= 15 && !mobile ||
browser == "Firefox" && version >= 58 && !mobile ||
browser == "Chrome" && version >= 49 && !mobile ||
browser == "Safari" && version >= 11 && !mobile ||
browser == "Safari" && version >= 10 && mobile && osVersion >= 5 ||
browser == "Chrome" && version >= 64 && mobile && osVersion >= 5
;

} catch (e) {
this.allowsDrop = false;
this.allowsDirectorySelect = false;
this.allowsMultiFileSelect = false;
}

this.path = ko.observable();
this.name = ko.observable();
Expand Down
4 changes: 2 additions & 2 deletions edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ <h3 id="addDialogLabel">Timepoint Tour Editor</h3>
</div>

<div class="control-group" style="width: 100%">
<label class="control-label" for="spatial-group-timeslot" title="The time the panoramas were shot. This determines the position on the timeline.">Timeslot</label>
<label class="control-label" for="timeslot" title="The time the panoramas were shot. This determines the position on the timeline.">Timeslot</label>
<div class="controls">
<div class='input-group date' id='spatial-group-timeslot' data-bind="dateTimePicker: timeslot" data-target-input="nearest">
<div class='input-group date' id='timeslot' data-bind="dateTimePicker: timeslot" data-target-input="nearest">
<input type='text' class="form-control datetimepicker-input" data-target="#timeslot" />
<span class="input-group-addon" data-target="#timeslot" data-toggle="datetimepicker">
<span class="glyphicon glyphicon-calendar"></span>
Expand Down
4 changes: 2 additions & 2 deletions mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ <h3 id="addDialogLabel">Timepoint Tour Editor</h3>
</div>

<div class="control-group" style="width: 100%">
<label class="control-label" for="spatial-group-timeslot" title="The time the panoramas were shot. This determines the position on the timeline.">Timeslot</label>
<label class="control-label" for="timeslot" title="The time the panoramas were shot. This determines the position on the timeline.">Timeslot</label>
<div class="controls">
<div class='input-group date' id='spatial-group-timeslot' data-bind="dateTimePicker: timeslot" data-target-input="nearest">
<div class='input-group date' id='timeslot' data-bind="dateTimePicker: timeslot" data-target-input="nearest">
<input type='text' class="form-control datetimepicker-input" data-target="#timeslot" />
<span class="input-group-addon" data-target="#timeslot" data-toggle="datetimepicker">
<span class="glyphicon glyphicon-calendar"></span>
Expand Down

0 comments on commit 91faa8e

Please sign in to comment.