Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/upload test #82

Open
wants to merge 67 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
f946b0b
Add style to allow word to be break and wrap
JamieHo3312 Apr 18, 2016
6230d9c
Update the style to place in the middle of the table
JamieHo3312 Apr 18, 2016
3b1c6e8
Remove angular-breadcrumb & implement breadcrumb component
Apr 21, 2016
2f1e1dc
Add base style for display property
JamieHo3312 Apr 21, 2016
d0227f2
Fix flexbox type layout issues in IE10
JamieHo3312 Apr 21, 2016
ce606a8
Add list item style for file list
JamieHo3312 Apr 21, 2016
ef3ccc9
Design file list
JamieHo3312 Apr 21, 2016
e7ad670
Change the accent theme grey to indigo
JamieHo3312 Apr 21, 2016
b17959d
Add File component
Apr 21, 2016
0a18a11
Remove angular-breadcrumb from source code
Apr 21, 2016
9ea4a82
Add click event to bucket component
Apr 22, 2016
dfb26b3
Add sample view & service to file component
Apr 22, 2016
3146d6e
Rename utils to services
Apr 25, 2016
e782e35
Move natural sotr function to utils for reusable
Apr 25, 2016
55f211c
Replace upload and create folder icon
JamieHo3312 Apr 26, 2016
dd78031
Add dialog-footer and list-dialog style
JamieHo3312 Apr 27, 2016
57bc03a
Add the ui of upload file
JamieHo3312 Apr 27, 2016
7f836dd
Real api call
May 6, 2016
745928e
Merge remote-tracking branch 'jamie/feature/design-file-list' into fe…
May 6, 2016
ad02be3
Bind controller properties to view
May 6, 2016
6fc82ff
Update $file service
May 6, 2016
635cf94
Merge branch 'dev' into feature/implement-breadcrumb
May 16, 2016
ce3cdb1
fix bug in action-navbar.html
May 16, 2016
46cf39a
Merge branch 'dev' into feature/files-list-component
May 16, 2016
b521b34
Merge branch 'feature/implement-breadcrumb' into feature/files-list-c…
May 16, 2016
6679b83
Update file module
May 16, 2016
0a58ba8
Add ng-file-upload to dependencies
May 16, 2016
a356e99
Merge remote-tracking branch 'jamie/feature/design-upload-form' into …
May 16, 2016
d11309a
Add fileUpload to vendor and remove angular-breadcrumb
May 17, 2016
6b3d4af
Add filesize filter for size format
May 17, 2016
f71b02c
Add align style for set the vertical alignment
JamieHo3312 May 17, 2016
4fc9ec7
Add style for highlight the messages
JamieHo3312 May 17, 2016
37cc662
Design transfer view
JamieHo3312 May 17, 2016
5bbc8af
Update file.html
May 18, 2016
3d1c5c6
Remove unnecessary state and dependence in file.service.js
May 18, 2016
d90dfd1
Add file upload component
May 18, 2016
0054bd7
Add sign out handler
May 18, 2016
30283b7
Add method to Upload button in action navbar
May 18, 2016
f024de0
Fix breadcrumb bar
May 18, 2016
36bc561
Merge remote-tracking branch 'jamie/feature/design-transfer' into fea…
May 18, 2016
b8f6cff
Add transfer UI & update layout component
May 18, 2016
f46b0b1
Add transfer service
May 18, 2016
cf833f4
Remove transfer import in components/index.js
May 18, 2016
c931e89
Use boolean to control upadting status
May 18, 2016
48fadf8
Move toal size method to utils
May 18, 2016
d26b84b
Update method name
May 18, 2016
89fac79
Refactor upload component
May 18, 2016
35d0104
Merge branch 'feature/files-upload-component' into feature/transfer-c…
May 18, 2016
c0a0904
Update TokenInterceptor for other error handler
May 19, 2016
c98ab5b
Complete transfer component
May 19, 2016
f5df9e0
Fix bugs of toast message
May 19, 2016
e6b383d
Add $file dependence to $transfer
May 19, 2016
891ea2d
Update transfers & properties button of action navbar
May 19, 2016
3b7d1e4
Update properties event in actions button of action navbar
May 19, 2016
f9114a3
Fix bug when file size small than 1024 bytes
May 20, 2016
e0c66b0
Fix file icon in upload.html
May 20, 2016
9d9f9bb
Fix bug when action navbar switch
May 20, 2016
14d0269
Fix menu items of actions button
May 23, 2016
d8a9931
Fix bug when action navbar switch
May 20, 2016
854f751
Revert "Fix bug when action navbar switch"
May 23, 2016
de6b57f
Merge branch 'feature/files-upload-component' into feature/transfer-c…
May 23, 2016
c9c7b00
Fix menu items of actions button
May 23, 2016
aa3b916
Revert "Fix menu items of actions button"
May 23, 2016
d407d44
Merge branch 'feature/files-upload-component' into feature/transfer-c…
May 23, 2016
58a7748
Fix issue display upload completed icon
May 24, 2016
d1d3b78
Add unit test for upload component
May 24, 2016
5251cfd
Add Testing method upload, createDialog, closeDialog in uploadService.
May 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"angular": "^1.5.0",
"angular-animate": "^1.5.0",
"angular-aria": "^1.5.0",
"angular-breadcrumb": "^0.4.1",
"angular-material": "^1.0.5",
"angular-messages": "^1.5.0",
"angular-translate": "^2.9.2",
Expand All @@ -49,6 +48,7 @@
"javascript-natural-sort": "^0.7.1",
"lodash": "^4.5.1",
"material-design-icons": "^2.2.0",
"ng-file-upload": "^12.0.4",
"satellizer": "^0.14.0"
},
"devDependencies": {
Expand Down
9 changes: 7 additions & 2 deletions src/components/bucket/bucket.controller.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
export default class BucketController {
/** @ngInject */
constructor($scope, $bucket) {
constructor($scope, $bucket, $state, $breadcrumb) {
Object.assign(this, {
$scope, $bucket,
$scope, $bucket, $state,
});

this.$scope.$watch(
() => $bucket.state.lists,
newVal => Object.assign(this, newVal)
, true);

$breadcrumb.initPaths();
this.$bucket.getBuckets();
}

createBucket($event) {
this.$bucket.createDialog($event);
}

selectBucket(bucket) {
this.$state.go('file', { path: bucket });
}
}
5 changes: 2 additions & 3 deletions src/components/bucket/bucket.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
</thead>

<tbody>
<tr ng-repeat="bucket in bucket.data" ng-class="{active:@A.3}">
<tr ng-repeat="b in bucket.data" ng-class="{active:@A.3}">
<td>
<a ng-click="@A.4">
<md-icon>info_outline</md-icon>
</a>
</td>
<td ng-bind="bucket.Name">
<a ng-click="@A.11"></a>
<td ng-bind="b.Name" ng-click="bucket.selectBucket(b.Name)">
</td>
</tr>
</tbody>
Expand Down
3 changes: 0 additions & 3 deletions src/components/bucket/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const route = $stateProvider => {
controllerAs: 'bucket',
template: BucketTemplate,
onEnter: $nav => $nav.setTypeToBucket(),
ncyBreadcrumb: {
label: 'All Buckets ( {{ bucket.data.length }} )',
},
});
};

Expand Down
25 changes: 6 additions & 19 deletions src/components/bucket/bucket.service.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { element } from 'angular';
import natural from 'javascript-natural-sort';
import { sortByName } from '../../utils/sort';
import BucketCreateController from './create/create.controller';
import BucketCreateTemplate from './create/create.html';

export default class BucketService {
/** @ngInject */
constructor($fetch, $toast, $mdDialog) {
constructor($fetch, $toast, $mdDialog, $breadcrumb) {
Object.assign(this, {
$fetch, $toast, $mdDialog,
$fetch, $toast, $mdDialog, $breadcrumb,
});

this.initState();
Expand Down Expand Up @@ -73,20 +73,6 @@ export default class BucketService {
this.resetCheckBucketState();
}

/**
* Natural sort for the specified object key.
*
* @param {Object} a
* @param {Object} b
* @return {Integer}
*/
sortByName(a, b) {
const x = a.Name;
const y = b.Name;

return natural(x, y);
}

/**
* Call the bucket list API and modify the state of service.
*
Expand All @@ -99,13 +85,14 @@ export default class BucketService {
this.$fetch.post('/v1/bucket/list')
.then(({ data }) => {
this.state.lists.error = false;
this.state.lists.data = data.Buckets.sort(this.sortByName);
this.state.lists.data = data.Buckets.sort(sortByName);
})
.catch(() => {
this.state.lists.error = true;
})
.finally(() => {
this.state.lists.requesting = false;
this.$breadcrumb.updateBucketPath(this.state.lists.data.length);
});
}

Expand Down Expand Up @@ -140,7 +127,7 @@ export default class BucketService {
createBucket(bucket) {
this.$fetch.post('/v1/bucket/create', { bucket })
.then(({ data }) => {
this.state.lists.data = data.Buckets.sort(this.sortByName);
this.state.lists.data = data.Buckets.sort(sortByName);
this.$toast.show(`Bucket ${bucket} has created!`);
})
.catch(() => {
Expand Down
34 changes: 34 additions & 0 deletions src/components/file/file.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export default class FileController {
/** @ngInject */
constructor($scope, $stateParams, $file, $bucket, $breadcrumb, $upload) {
Object.assign(this, {
$file, $upload, $bucket, $breadcrumb,
});

$scope.$watch(
() => $file.state.lists,
newVal => Object.assign(this, newVal)
, true);

const paths = $stateParams.path.split('/');
const [bucket, ...folders] = paths;

this.$file.setPaths(bucket, folders);
this.$breadcrumb.updateFilePath(paths);

this.$bucket.getBuckets();
this.$file.getFiles();
}

createFolder($event) {
this.$file.createFolder($event);
}

upload($event) {
this.$upload.createDialog($event);
}

refresh() {
this.$file.getFiles();
}
}
24 changes: 24 additions & 0 deletions src/components/file/file.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

/**
* @author Jamie jamie.h@inwinstack.com
*/

.checkbox-icon-width {
width: 80px;
}

.storage-class-width {
width: 140px;
}

.size-width {
width: 84px;
}

.time-width {
width: 270px;
}

.time-title-width {
width: 286px;
}
99 changes: 99 additions & 0 deletions src/components/file/file.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<md-content layout-padding>
<div
class="md-whiteframe-4dp"
ng-if="file.data.length && ! file.requesting && ! file.error"
>
<table class="table table-cursor table-hover">
<thead>
<tr>
<th class="checkbox-icon-width"></th>
<th>Name</th>
<th class="hide show-gt-sm storage-class-width">Storage Class</th>
<th class="size-width">Size</th>
<th class="hide show-gt-sm time-title-width">Last Modified</th>
</tr>
</thead>
</table>
<md-list>
<md-list-item ng-class="{checked:message.selected}" ng-repeat="f in file.data">
<md-checkbox ng-model="message.selected"></md-checkbox>
<md-icon>insert_drive_file</md-icon>
<p class="break-word flex-grow">
<span ng-bind="f.Key"></span>
</p>
<p class="flex-none" hide show-gt-sm>
<span
class="storage-class-width inline-block"
ng-bind="f.StorageClass"
></span>
</p>
<p class="flex-none">
<span
class="size-width inline-block"
ng-bind="(f.Size | filesize)"
></span>
</p>
<p class="flex-none" hide show-gt-sm>
<span
class="time-width inline-block"
ng-bind="(f.LastModified | date: 'yyyy-MM-dd')"
></span>
</p>
</md-list-item>
</md-list>
</div>

<div
class="progress-state"
layout="column" layout-align="center center"
ng-if="file.requesting"
>
<md-progress-circular md-mode="indeterminate" md-diameter="70"></md-progress-circular>
<div class="md-headline">Loading...</div>
</div>

<div
class="empty-state"
layout="column" layout-align="center center"
ng-if="! file.data.length && ! file.requesting && ! file.error"
>
<div class="md-headline">This bucket is empty</div>
<div class="md-subhead">You can do the following actions</div>

<div layout="row" layout-align="center center">
<md-button
class="md-raised md-primary" aria-label="Upload File"
ng-click="file.upload()"
>
<md-icon>file_upload</md-icon>
<span>Upload File</span>
</md-button>

<span>or</span>

<md-button
class="md-raised" aria-label="Create Folder"
ng-click="file.createFolder()"
>
<md-icon class="material-icons">create_new_folder</md-icon>
<span>Create Folder</span>
</md-button>
</div>
</div>

<div
class="load-fail-state"
layout="column" layout-align="center center"
ng-if="file.error && ! file.requesting"
>
<div class="md-headline">Oops, your connection seems off...</div>
<div class="md-subhead">Don't worry. You can refresh to try again.</div>

<md-button
class="md-icon-button" aria-label="Refresh"
ng-click="file.refresh()"
>
<md-icon class="icon-default">refresh</md-icon>
</md-button>
</div>
</md-content>
29 changes: 29 additions & 0 deletions src/components/file/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { module } from 'angular';
import router from 'angular-ui-router';

import FileController from './file.controller';
import FileService from './file.service';
import FileTemplate from './file.html';
import UploadService from './upload/upload.servce';
import './file.css';

/** @ngInject */
const route = $stateProvider => {
$stateProvider.state('file', {
url: '/bucket/*path',
parent: 'root',
controller: FileController,
controllerAs: 'file',
template: FileTemplate,
onEnter: $nav => $nav.setTypeToFile(),
});
};

const File = module('file', [
router,
])
.service('$file', FileService)
.service('$upload', UploadService)
.config(route);

export default File.name;
49 changes: 49 additions & 0 deletions src/components/file/file.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export default class FileService {
/** @ngInject */
constructor($mdDialog, $fetch, $bucket) {
Object.assign(this, {
$mdDialog, $fetch, $bucket,
});

this.initState();
}

initState() {
this.state = {
paths: {
bucket: '',
folders: [],
},
lists: {
data: [],
requesting: false,
error: false,
},
};
}

setPaths(bucket, folders) {
this.paths = { bucket, folders };
}

getFiles() {
const { bucket, folders } = this.paths;
const endpoint = `/v1/file/list/${bucket}?prefix=${folders.join('/')}`;

this.state.lists.requesting = true;
this.state.lists.data = [];

this.$fetch
.get(endpoint)
.then(({ data }) => {
this.state.lists.error = false;
this.state.lists.data = data.files || [];
})
.catch(() => {
this.state.lists.error = true;
})
.finally(() => {
this.state.lists.requesting = false;
});
}
}