Skip to content

Commit

Permalink
Added delete and hard delete functionality, fixed resize items change…
Browse files Browse the repository at this point in the history
… fullscreen to maximize, added f12 to devtools
  • Loading branch information
EladBezalel committed Mar 11, 2015
1 parent 54bea7d commit 9920ff7
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 20 deletions.
4 changes: 2 additions & 2 deletions client/app/main/side-nav/side-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
</md-toolbar>
<div layout="column">
<md-subheader>Drives</md-subheader>
<md-button aria-label="drive" ng-click="goToDir('E:')">E:</md-button>
<md-button aria-label="drive" ng-click="goToDir('C:')">C:</md-button>
<md-button aria-label="drive" ng-click="goToDir('E:\\')">E:</md-button>
<md-button aria-label="drive" ng-click="goToDir('C:\\')">C:</md-button>
</div>
</md-sidenav>
</div>
33 changes: 25 additions & 8 deletions client/app/main/view/view.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ angular.module('fileExplorerApp')
var async = require('async');
var path = require('path');
var _ = require('lodash');
var shell = require('nw.gui').Shell;
var gui = require('nw.gui');
var shell = gui.Shell;
var nativeApi = require('native-api');
var nativeFile = nativeApi.file;
var directory = $stateParams.path;
Expand Down Expand Up @@ -80,7 +81,8 @@ angular.module('fileExplorerApp')
}
};

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'right',
description: 'Select the item on the right of the selected item',
callback: function () {
Expand All @@ -95,7 +97,8 @@ angular.module('fileExplorerApp')
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'left',
description: 'Select the item on the left of the selected item',
callback: function () {
Expand All @@ -110,7 +113,8 @@ angular.module('fileExplorerApp')
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'down',
description: 'Select the item below the selected item',
callback: function () {
Expand All @@ -125,7 +129,8 @@ angular.module('fileExplorerApp')
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'up',
description: 'Select the item on top of the selected item',
callback: function () {
Expand All @@ -139,15 +144,17 @@ angular.module('fileExplorerApp')
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'enter',
description: 'Open selected item',
callback: function () {
$scope.openItem($scope.items[$scope.selectedItemIndex]);
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: '+',
description: 'Increase number of items per row (should be ctrl++ not working for now)',
callback: function () {
Expand All @@ -157,7 +164,8 @@ angular.module('fileExplorerApp')
}
});

hotkeys.add({
hotkeys.bindTo($scope)
.add({
combo: 'ctrl+-',
description: 'Decrease number of items per row',
callback: function () {
Expand All @@ -166,4 +174,13 @@ angular.module('fileExplorerApp')
}
}
});

hotkeys.bindTo($scope)
.add({
combo: 'f12',
callback: function () {
gui.Window.get().showDevTools();
}
});

});
3 changes: 2 additions & 1 deletion client/app/main/view/view.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div layout="row" layout-wrap layout-padding>
<div layout="row" layout-wrap layout-padding layout-align="space-between">
<div flex="{{ 5 * Math.floor(100 / itemsPerRow / 5) }}" ng-repeat="item in items track by item.path" class="file"
ng-click="selectItem($index)" ng-dblclick="openItem(item)"
ng-class="{ selected: selectedItemIndex == $index }">
Expand All @@ -11,4 +11,5 @@
<span>{{ item.name }}</span>
</div>
</div>
<div flex ng-hide="items.length % itemsPerRow == 0"></div>
</div>
7 changes: 6 additions & 1 deletion client/app/shell/shell.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ angular.module('fileExplorerApp')
};

$scope.toggleFullscreen = function (){
if(!$scope.isFullScreen){
nwin.maximize();
}
else{
nwin.unmaximize();
}
$scope.isFullScreen = !$scope.isFullScreen;
nwin.toggleFullscreen();
};

$scope.hide = function (){
Expand Down
53 changes: 51 additions & 2 deletions client/app/side-panel/side-panel.controller.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,58 @@
'use strict';

angular.module('fileExplorerApp')
.controller('SideBarController', function ($scope) {
.controller('SideBarController', function ($scope, $mdDialog, hotkeys) {
var trash = require('trash');
var rimraf = require('rimraf')

$scope.item = {};
$scope.$on('ItemSelected', function(ev, item) {
$scope.$on('ItemSelected', function (ev, item) {
$scope.item = item;
});

$scope.deleteItem = function () {

trash([$scope.item.path], function (err) {
console.log(err);
});
};

hotkeys.bindTo($scope)
.add({
combo:'del',
callback: function(){
$scope.deleteItem();
}
});

hotkeys.bindTo($scope)
.add({
combo: 'shift+del',
callback: function(){
var confirm = {};

if ($scope.item.isFolder) {
confirm = $mdDialog.confirm()
.title('Delete folder')
.content('Are you sure you want to permanently delete \'' + $scope.item.name + '\' folder?')
.ok('I\'m sure')
.cancel('Cancel');
}
else {
confirm = $mdDialog.confirm()
.title('Delete file')
.content('Are you sure you want to permanently delete \'' + $scope.item.name + '\'?')
.ok('I\'m sure')
.cancel('Cancel');
}
$mdDialog.show(confirm).then(function () {
rimraf($scope.item.path, function (err){
if (err){
console.log(err);
}

});
});
}
});
});
6 changes: 4 additions & 2 deletions client/app/side-panel/side-panel.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<div ng-controller="SideBarController" class="side-panel" flex>
<md-toolbar class="md-tall tool-bar" layout="row">
<div flex layout="column" layout-align="space-between start">
<div class="md-toolbar-tools">
<span></span>
<div class="md-toolbar-tools" layout="row" layout-align="end">
<md-button ng-click="deleteItem($event)">
<i class="mdi mdi-delete"></i>
</md-button>
</div>
<div class="md-toolbar-tools md-toolbar-tools-bottom">
<div layout="column">
Expand Down
2 changes: 1 addition & 1 deletion client/components/explorer/explorer.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ angular.module('fileExplorerApp')
this.setSelectedItems = setSelectedItems;
this.getSelectedItems = getSelectedItems;

setCurrentPath('C:');
setCurrentPath('C:\\');
});
2 changes: 1 addition & 1 deletion client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
<script src="app/side-panel/side-panel.controller.js"></script>
<script src="components/explorer/explorer.service.js"></script>
<script src="app/main/side-nav/side-nav.controller.js"></script>
<script src="app/main/toolbar/toolbar.controller.js"></script>
<script src="app/main/view/view.controller.js"></script>
<script src="app/main/view/view.js"></script>
<script src="app/main/toolbar/toolbar.controller.js"></script>
<script src="app/common/filters/bytes/nch-bytes.filter.js"></script>
<!-- endinjector -->
</body>
Expand Down
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Nachos default file explorer",
"main": "index.html",
"window": {
"toolbar": true,
"toolbar": false,
"frame": false,
"position": "center",
"fullscreen": false,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
"async": "^0.9.0",
"lodash": "^3.3.1",
"native-api": "git://github.com/nachos/native-api",
"nw": "^0.12.0"
"nw": "^0.12.0",
"rimraf": "^2.3.2",
"trash": "^1.4.1"
}
}

0 comments on commit 9920ff7

Please sign in to comment.