33 Commits

Author SHA1 Message Date
db87ecb76e 0.7.1 2018-01-03 19:57:26 +00:00
afa1552ebf Fix race condition with documents filtering 2018-01-03 19:48:55 +00:00
174f69f84d 0.7.0 2018-01-03 19:36:29 +00:00
9f5d8bfb93 Delete all documents in current directory
Adds a new button to the top right for deleting all documents in a
directory.
2018-01-03 13:34:04 +00:00
f9b4444763 Use published widget again
The necessary changes have been released in 1.2.0
2018-01-02 13:11:01 +00:00
bdb0671171 0.6.1 2017-12-31 18:40:35 +00:00
14c39d292f Prevent error alert for discovery errors
They're handled by the widget
2017-12-31 18:40:08 +00:00
8f7b861347 0.6.0 2017-12-31 18:29:29 +00:00
ab9ad2f354 Handle invalid RS auth tokens 2017-12-31 13:35:25 +01:00
ab637deb33 Add delete button 2017-12-30 20:24:40 +01:00
220888a7c5 Move header to route templates, remove obsolete code 2017-12-30 20:05:41 +01:00
f681524599 Update package lockfile 2017-12-30 20:05:27 +01:00
554e661ad6 0.5.1 2017-12-26 14:56:17 +01:00
e4520d86c3 Fix file preview content not breaking 2017-12-26 14:55:37 +01:00
a27d142b4b 0.5.0 2017-12-26 14:02:04 +01:00
89b846c511 Show disconnect link on hover 2017-12-26 14:01:43 +01:00
b8604bacb5 Add basic disconnect link 2017-12-26 13:53:21 +01:00
36901b8006 Use new skipInitial widget option 2017-12-26 13:53:03 +01:00
2e4b5a0337 Add disconnect route 2017-12-26 12:16:18 +01:00
f7142fa125 Fix widget style on connect page 2017-12-26 12:16:03 +01:00
e38e873dd2 Style user address (with username seperate from host) 2017-12-26 12:03:40 +01:00
0a41be32fd Fix route test 2017-12-26 12:03:32 +01:00
5d533d2c08 More connect improvements
* Use extra route for disconnected/initial state
* Style connect screen properly
* Hide widget when connected in favor of custom UI
* Show account info in sidebar header
2017-12-25 10:50:03 +01:00
07be7dece8 0.4.0 2017-12-24 10:57:19 +01:00
b5418a15c8 Update package.json 2017-12-24 10:56:58 +01:00
0ee09d99ce Wait for connection state before fetching anything
This ensures that no data is fetched prematurely.
2017-12-24 10:53:27 +01:00
456e1f15fb More connection handling 2017-12-24 10:52:41 +01:00
e865ffe073 Improve connection handling
* Clear directory data on disconnect
* Clear path URL param on disconnect
* Don't try to fetch dir listing when starting app disconnected
2017-12-22 12:54:29 +01:00
b49cb5c50e Add current developmen status to README 2017-12-17 16:10:39 +00:00
92d4b5c73d Update README 2017-12-17 16:02:08 +00:00
a121128d28 Improve deployment 2017-12-17 15:52:16 +00:00
ea587b502b Pull build branch before deployment routine 2017-12-17 15:48:52 +00:00
579757dee2 Set up deployment 2017-12-17 15:47:03 +00:00
31 changed files with 1692 additions and 59 deletions

View File

@@ -199,7 +199,7 @@ linters:
style: one_space # or 'at_least_one_space', or 'no_space'
SpaceBeforeBrace:
enabled: true
enabled: false
style: space # or 'new_line'
allow_single_line_padding: false

View File

@@ -1,7 +1,27 @@
# inspektor
# RS Inspektor
This README outlines the details of collaborating on this Ember application.
A short introduction of this app could easily go here.
Inspektor is a simple file browser for inspecting the contents of a
[remoteStorage](https://remotestorage.io) account. It is intended for RS app
developers and power users.
Inspektor is beta software and currently under development. You're invited to
contribute and/or give feedback: https://gitlab.com/skddc/inspektor
## Features
* [x] Connect RS accounts
* [x] Traverse/inspect directories
* [x] View document details
* [x] Render images in details
* [x] Render text content in details (e.g. JSON)
* [ ] Render other types content (e.g. audio and video)
* [ ] Edit text content (and save changes)
* [ ] Delete documents
* [ ] Delete directories
* [ ] Copy/move documents
* [ ] Copy/move directories (and enclosed files)
* [ ] Loading indicator for any view change that loads remote data
* [ ] Logo/icon
## Prerequisites
@@ -40,7 +60,14 @@ Make use of the many generators for code, try `ember help generate` for more det
### Deploying
Specify what it takes to deploy your app.
With the 5apps remote added correctly (and push access to the GitLab repo),
just run:
npm run deploy
If you want to deploy this from and to different repos, have a look at the
`scripts` section in `package.json`, as well as `scripts/deploy.sh` for how it
works.
## Further Reading / Useful Links

View File

@@ -0,0 +1,18 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
export default Component.extend({
classNames: ['account-info'],
userAddress: null,
username: computed('userAddress', function() {
return this.get('userAddress').split('@')[0];
}),
host: computed('userAddress', function() {
return '@' + this.get('userAddress').split('@')[1];
})
});

View File

@@ -0,0 +1,4 @@
<span class="username">{{username}}</span>
<br><span class="host">{{host}}</span>
{{#link-to "disconnect" class="disconnect"}}disconnect{{/link-to}}

View File

@@ -1,8 +1,8 @@
import Controller from '@ember/controller';
import EmberObject from '@ember/object';
import { computed, observer } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import { observer } from '@ember/object';
import { isEmpty } from '@ember/utils';
export default Controller.extend({
@@ -11,10 +11,12 @@ export default Controller.extend({
connecting: alias('storage.connecting'),
connected: alias('storage.connected'),
userAddress: alias('storage.userAddress'),
rootListing: alias('storage.rootListing'),
currentDirPath: null,
handleConnected: observer('connected', function() {
this.get('storage').fetchRootListing();
connectedClass: computed('connected', function() {
return this.get('connected') ? 'connected' : 'disconnected';
}),
categories: function() {
@@ -33,8 +35,14 @@ export default Controller.extend({
});
return categories;
}.property('rootListing')
}.property('rootListing'),
connectedChange: observer('connected', function() {
if (this.get('connected')) {
// console.debug('connectedChange connected');
} else {
this.set('currentDirPath', null);
}
}),
});

View File

@@ -1,27 +1,87 @@
import Controller from '@ember/controller';
import { inject as controller } from '@ember/controller';
import { inject as service } from '@ember/service';
import { computed, observer } from '@ember/object';
import { alias } from '@ember/object/computed';
import { isPresent } from '@ember/utils';
import { isPresent, isEmpty } from '@ember/utils';
import { all } from 'rsvp';
export default Controller.extend({
application: controller(),
storage: service(),
// connecting: alias('storage.connecting'),
// connected: alias('storage.connected'),
connected: alias('storage.connected'),
rootListing: alias('storage.rootListing'),
currentDirPath: alias('application.currentDirPath'),
queryParams: ['path'],
currentListing: function() {
currentListing: function () {
if (isPresent(this.get('model.currentListing'))) {
return this.get('model.currentListing').sortBy('name');
} else {
return this.get('rootListing');
}
}.property('rootListing.[]', 'model.[]')
}.property('rootListing.[]', 'model.[]'),
documents: computed('currentListing.[]', function () {
if (isEmpty(this.get('currentListing'))) { return []; }
return this.get('currentListing')
.reject(item => item.path.substr(-1) === '/');
}),
currentListingContainsDocuments: computed('documents.[]', function () {
return isPresent(this.get('documents'));
}),
documentCount: computed('documents.[]', function () {
if (isPresent(this.get('documents'))) {
return this.get('documents').length;
} else {
return 0;
}
}),
parentDir: computed('currentDirPath', function () {
const dirs = this.get('currentDirPath')
.split('/')
.reject(p => isEmpty(p));
return dirs.splice(0, dirs.length - 1).join('/') + '/';
}),
connectedChange: observer('connected', function () {
if (this.get('connected')) {
// console.debug('connectedChange connected');
} else {
this.set('model', null);
this.set('path', null);
}
}),
actions: {
deleteDocuments () {
const documentCount = this.get('documentCount');
const msg = `This will delete all ${documentCount} documents/files in the current directory. Are you sure?`;
if (! window.confirm(msg)) { return false; }
const client = this.get('storage.client');
let promises = this.get('documents').map(item => {
console.debug('removing ' + item.path);
return client.remove(item.path);
});
all(promises).then(() => {
this.transitionToRoute('index', {
queryParams: { path: this.get('parentDir') }
});
});
}
}
});

View File

@@ -12,4 +12,21 @@ export default Controller.extend({
queryParams: ['path'],
actions: {
deleteItem () {
if (window.confirm('Sure?')) {
this.get('storage.client')
.remove(this.get('path')).then(() => {
this.transitionToRoute('index', {
queryParams: {
path: this.get('currentDirPath')
}
});
});
}
}
}
});

View File

@@ -8,6 +8,8 @@ const Router = EmberRouter.extend({
Router.map(function() {
this.route('inspect');
this.route('connect');
this.route('disconnect');
});
export default Router;

View File

@@ -1,5 +1,38 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import BodyClassMixin from 'ember-body-class/mixins/body-class';
export default Route.extend({
export default Route.extend(BodyClassMixin, {
storage: service(),
beforeModel () {
this.get('storage.rs').on('error', (error) => {
console.debug('rs.on error', error);
if (error.name === 'Unauthorized') {
this.handleUnauthorized();
} else if (error.name === 'DiscoveryError') {
// Do nothing, because the widget will handle it
} else {
alert('An unknown error occured. Please check the browser console for details.');
}
});
},
// We need to handle this here, so we can transitionTo
// the connect route
handleUnauthorized () {
// Ignore additional unauthorized events after the
// first one
if (this.get('storage.unauthorized')) { return; }
this.get('storage').setProperties({
unauthorized: true,
connecting: false,
connected: false
});
this.transitionTo('connect');
}
});

33
app/routes/connect.js Normal file
View File

@@ -0,0 +1,33 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { later } from '@ember/runloop';
import { Promise } from 'rsvp';
export default Route.extend({
storage: service(),
beforeModel() {
return this.waitForConnectionState().then(() => {
if (this.get('storage.connected')) {
this.transitionTo('index');
}
});
},
waitForConnectionState() {
let self = this;
return new Promise(resolve => {
function checkConnectingDone() {
if (self.get('storage.connecting')) {
later(checkConnectingDone, 20);
} else {
resolve();
}
}
checkConnectingDone();
});
}
});

13
app/routes/disconnect.js Normal file
View File

@@ -0,0 +1,13 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
storage: service(),
beforeModel() {
this.get('storage.rs').disconnect();
this.transitionTo('connect');
}
});

View File

@@ -1,7 +1,8 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { isEmpty, isPresent } from '@ember/utils';
import { hash } from 'rsvp';
import { later } from '@ember/runloop';
import { hash, Promise } from 'rsvp';
export default Route.extend({
@@ -13,6 +14,14 @@ export default Route.extend({
}
},
beforeModel() {
return this.waitForConnectionState().then(() => {
if (this.get('storage.disconnected')) {
this.transitionTo('connect');
}
});
},
model(params) {
let path = params.path;
@@ -35,7 +44,28 @@ export default Route.extend({
if (isPresent(model)) {
controller.set('currentDirPath', model.currentDirPath);
if (isEmpty(model.currentListing)) {
this.transitionTo('index', {
queryParams: { path: controller.get('parentDir') }
});
}
}
},
waitForConnectionState() {
let self = this;
return new Promise(resolve => {
function checkConnectingDone() {
if (self.get('storage.connecting')) {
later(checkConnectingDone, 20);
} else {
resolve();
}
}
checkConnectingDone();
});
}
});

View File

@@ -1,5 +1,7 @@
import EmberObject from '@ember/object';
import Service from '@ember/service';
import { computed, observer } from '@ember/object';
import { isEmpty } from '@ember/utils';
import RemoteStorage from 'npm:remotestoragejs';
import Widget from 'npm:remotestorage-widget';
import simpleContentType from 'inspektor/utils/simple-content-type';
@@ -10,6 +12,9 @@ export default Service.extend({
widget: null,
connecting: true,
connected: false,
unauthorized: false,
userAddress: null,
disconnected: computed.not('connected'),
client: null,
rootListing: null,
@@ -26,7 +31,7 @@ export default Service.extend({
// });
const widget = new Widget(rs, {
// leaveOpen: true
skipInitial: true
});
// Attach widget to DOM
@@ -41,6 +46,7 @@ export default Service.extend({
console.debug('rs.on connected');
this.set('connecting', false);
this.set('connected', true);
this.set('userAddress', this.get('rs').remote.userAddress);
});
rs.on('not-connected', () => {
@@ -72,6 +78,21 @@ export default Service.extend({
this.set('client', rs.scope('/'));
}.on('init'),
connectedChange: observer('connected', function() {
if (this.get('connected')) {
this.fetchRootListing();
} else {
this.clearLocalData();
}
}),
clearLocalData() {
this.setProperties({
userAddress: null,
rootListing: null
});
},
fetchRootListing() {
this.fetchListing('').then(items => {
this.set('rootListing', items.sortBy('name'));
@@ -82,6 +103,8 @@ export default Service.extend({
let items = [];
return this.get('client').getListing(path).then(listing => {
if (isEmpty(listing)) { return []; }
Object.keys(listing).forEach(name => {
let item = listing[name];
let type = item['Content-Type'] || 'folder';

View File

@@ -4,7 +4,14 @@ $dark-grey-3: #aaa;
$light-grey-1: #b5c3d1;
$light-grey-2: #ececec;
body {
background-color: #fff;
transition: background-color 0.2s linear;
}
#app-container {
background-color: #fff;
> aside {
background-color: $dark-grey-1;
color: $light-grey-1;
@@ -19,7 +26,6 @@ $light-grey-2: #ececec;
}
> main {
// background-color: $dark-grey-2;
background-color: #fff;
> header {
@@ -32,4 +38,8 @@ $light-grey-2: #ececec;
}
}
}
&.disconnected main {
background-color: $light-grey-2;
}
}

View File

@@ -3,12 +3,24 @@
}
#remotestorage-widget {
position: fixed;
top: 1rem;
right: 3rem;
z-index: 1;
display: none;
position: absolute;
top: 20%;
left: 50%;
margin-left: -200px;
z-index: 23;
}
.connect #remotestorage-widget {
display: block;
}
// .index #remotestorage-widget {
// position: fixed;
// top: 1rem;
// right: 3rem;
// }
#app-container {
position: absolute;
top: 0;
@@ -21,24 +33,52 @@
justify-content: flex-start;
align-items: stretch;
> aside {
flex: 0 0 16rem;
overflow: auto;
padding: 2rem;
nav {
margin-top: 5rem;
margin-bottom: 4rem;
&.disconnected {
> aside {
flex: 0;
overflow: hidden;
}
}
&.connected {
> aside {
flex: 0 0 16rem;
overflow: auto;
padding: 2rem;
}
}
> aside {
transition: flex 0.2s ease-in;
.account-info {
height: 5rem;
}
// nav {
// margin-top: 5rem;
// margin-bottom: 4rem;
// }
}
> main {
flex: 1;
overflow: auto;
padding: 3rem 4rem;
> header {
height: 4em;
height: 4rem;
display: flex;
flex-direction: row;
nav.breadcrumb-nav {
flex: 1;
}
nav.actions {
flex: 1;
text-align: right;
}
}
}
}
@@ -53,11 +93,12 @@
padding: 1.5rem 1px;
&.content {
// foo
overflow: hidden;
}
&.meta {
grid-column-start: 3;
overflow: hidden;
dl {
margin: 0;

View File

@@ -16,6 +16,7 @@ body {
padding: 0;
}
@import "components/account-info";
@import "components/breadcrumb-nav";
@import "components/categories-nav";
@import "components/directory-listing";

View File

@@ -0,0 +1,28 @@
.account-info {
position: relative;
.username {
font-size: 1.4rem;
}
.host {
font-size: 0.8rem;
opacity: 0.7;
}
.disconnect {
display: inline-block;
margin-left: 0.5rem;
font-size: 0.8rem;
opacity: 0;
transition: opacity 0.2s linear;
}
&:hover {
.disconnect {
font-size: 0.8rem;
opacity: 1;
}
}
}

View File

@@ -1,8 +1,10 @@
.file-preview {
code {
overflow-wrap: break-word;
word-wrap: break-word;
word-break: break-all;
line-height: 1.5rem;
hyphens: none;
}
img {

View File

@@ -1,22 +1,11 @@
<div id="app-container">
<div id="app-container" class={{connectedClass}}>
<aside>
{{#if connected}}
{{account-info userAddress=userAddress}}
{{categories-nav categories=categories}}
{{/if}}
</aside>
<main>
<header>
{{#if connecting}}
<!-- Connecting... -->
{{else}}
{{#if connected}}
{{breadcrumb-nav currentDirPath=currentDirPath}}
{{else}}
Not connected.
{{/if}}
{{/if}}
</header>
{{outlet}}
</main>
</div>

View File

View File

@@ -0,0 +1 @@
{{outlet}}

View File

@@ -1,3 +1,12 @@
<header>
{{breadcrumb-nav currentDirPath=currentDirPath}}
<nav class="actions">
{{#if currentListingContainsDocuments}}
<button class="delete-all" {{action "deleteDocuments"}}>delete all</button>
{{/if}}
</nav>
</header>
{{#if currentListing}}
{{directory-listing items=currentListing}}
{{/if}}

View File

@@ -1,3 +1,10 @@
<header>
{{breadcrumb-nav currentDirPath=currentDirPath}}
<nav class="actions">
<button class="delete" {{action "deleteItem"}}>delete</button>
</nav>
</header>
<div class="inspect-details">
<section class="content">
{{file-preview metaData=model.documentMetaData

1139
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,23 +1,27 @@
{
"name": "inspektor",
"version": "0.0.0",
"version": "0.7.1",
"private": true,
"description": "Small description for inspektor goes here",
"description": "Inspect the contents of your remote storage",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "",
"repository": "gitlab:skddc/inspektor",
"scripts": {
"build": "ember build",
"build-prod": "ember build --environment production && npm run update-version-file",
"start": "ember server",
"test": "ember test"
"test": "ember test",
"deploy": "npm run build-prod && bash scripts/deploy.sh",
"update-version-file": "bash scripts/update-version-file.sh"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-body-class": "^0.4.0",
"ember-browserify": "^1.2.0",
"ember-cli": "~2.16.2",
"ember-cli-app-version": "^3.0.0",
@@ -39,7 +43,7 @@
"ember-resolver": "^4.0.0",
"ember-source": "~2.16.0",
"loader.js": "^4.2.3",
"remotestorage-widget": "^1.0.0",
"remotestorage-widget": "^1.2.0",
"remotestoragejs": "^1.0.0"
},
"engines": {

17
scripts/deploy.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
set -xe
# Check out build branch
git checkout build-production
# Copy from build dir to root
cp -r dist/* .
# Add all files
git add --all
# Commit build files
git commit -m "Update build - `date -u`"
# Push to 5apps for deployment
git push 5apps build-production:master
# Push build branch to collab repo
git push origin build-production:build-production
# Go back to master branch
git checkout master

10
scripts/update-version-file.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
echo $PACKAGE_VERSION > dist/VERSION

View File

@@ -0,0 +1,14 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
moduleForComponent('account-info', 'Integration | Component | account info', {
integration: true
});
test('it splits the user address into username and host', function(assert) {
this.set('userAddress', 'michielbdejong@unhosted.org');
this.render(hbs`{{account-info userAddress=userAddress}}`);
assert.equal(this.$('.username').text().trim(), 'michielbdejong');
assert.equal(this.$('.host').text().trim(), '@unhosted.org');
});

View File

@@ -4,8 +4,89 @@ moduleFor('controller:index', 'Unit | Controller | index', {
needs: ['controller:application', 'service:storage']
});
// Replace this with your real tests.
test('it exists', function(assert) {
test('#parentDir', function(assert) {
let controller = this.subject();
assert.ok(controller);
controller.set('currentDirPath', 'islands/spain/canaries/tenerife/');
assert.equal(controller.get('parentDir'), 'islands/spain/canaries/');
});
test('#currentListingContainsDocuments', function(assert) {
let controller = this.subject();
controller.set('currentListing', [
{
"name": "spain/",
"type": "folder",
"isBinary": false,
"isFolder": true,
"size": null,
"path": "/islands/spain/",
"etag": "885098000"
}
]);
assert.notOk(controller.get('currentListingContainsDocuments'),
'returns false when no documents are present');
controller.set('currentListing', [
{
"name": "spain/",
"type": "folder",
"isBinary": false,
"isFolder": true,
"size": null,
"path": "/islands/spain/",
"etag": "885098000"
},
{
"name": "lamu",
"type": "application/json",
"isBinary": false,
"isFolder": false,
"size": 202,
"path": "/islands/lamu",
"etag": "478058546"
}
]);
assert.ok(controller.get('currentListingContainsDocuments'),
'returns true when no documents are present');
});
test('#documentCount', function(assert) {
let controller = this.subject();
controller.set('currentListing', [
{
"name": "spain/",
"type": "folder",
"isBinary": false,
"isFolder": true,
"size": null,
"path": "/islands/spain/",
"etag": "885098000"
},
{
"name": "lamu",
"type": "application/json",
"isBinary": false,
"isFolder": false,
"size": 202,
"path": "/islands/lamu",
"etag": "478058546"
},
{
"name": "dominica",
"type": "application/json",
"isBinary": false,
"isFolder": false,
"size": 202,
"path": "/islands/dominica",
"etag": "929838541"
}
]);
assert.equal(controller.get('documentCount'), 2,
'returns the number of documents in the current listing');
});

View File

@@ -0,0 +1,10 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('route:connect', 'Unit | Route | connect', {
needs: ['service:storage']
});
test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});

View File

@@ -0,0 +1,10 @@
import { moduleFor, test } from 'ember-qunit';
moduleFor('route:disconnect', 'Unit | Route | disconnect', {
needs: ['service:storage']
});
test('it exists', function(assert) {
let route = this.subject();
assert.ok(route);
});