-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
220 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
EiskaltApp.controller('SettingsCtrl', function ($scope, $timeout, $modal, settings, EiskaltRPC) { | ||
$scope.settings = settings.settings | ||
|
||
$scope.reset = function() { | ||
angular.forEach($scope.settings, function (setting) { | ||
EiskaltRPC.SettingsGetSet(setting.key).success(function(value) { | ||
if (setting.type === 'number') { | ||
value = parseInt(value); | ||
} | ||
setting.value = value; | ||
}); | ||
}); | ||
EiskaltRPC.ListShare().success(function(shares) { | ||
$scope.shares = shares; | ||
}); | ||
}; | ||
$scope.reset(); | ||
|
||
$scope.save = function() { | ||
angular.forEach($scope.settings, function (setting) { | ||
EiskaltRPC.SettingsGetSet(setting.key, setting.value).success(function(success) { | ||
if (success) { | ||
setting.success = true; | ||
$timeout(function() { | ||
delete setting.success; | ||
}, 2000) | ||
} else { | ||
setting.error = true; | ||
} | ||
}); | ||
}); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"use strict"; | ||
|
||
EiskaltApp.controller('ShareCtrl', function ($scope, $modal, settings, EiskaltRPC) { | ||
$scope.directories = [] | ||
|
||
$scope.refresh = function () { | ||
EiskaltRPC.ListShare().success(function (directories) { | ||
$scope.directories = directories; | ||
}); | ||
}; | ||
$scope.refresh(); | ||
|
||
$scope.openAddShareDirModal = function () { | ||
$modal.open({ | ||
templateUrl: 'addShareDirModal.html', | ||
controller: 'AddShareDirCtrl' | ||
}).result.then($scope.refresh); | ||
}; | ||
|
||
$scope.removeShareDir = function (directory) { | ||
if (confirm( | ||
'Are you sure to unshare the directory ' + directory.name + '?\n' + | ||
'Rehashing ' + directory.sizeFormatted + ' may take a while.' | ||
)) { | ||
EiskaltRPC.DelDirFromShare(directory.name).success($scope.refresh); | ||
} | ||
} | ||
}); | ||
|
||
EiskaltApp.controller('AddShareDirCtrl', function ($scope, $modalInstance, EiskaltRPC) { | ||
$scope.name = ""; | ||
$scope.path = ""; | ||
|
||
$scope.ok = function () { | ||
EiskaltRPC.AddDirInShare($scope.path, $scope.name).success(function (result) { | ||
$modalInstance.close(result === 0); | ||
}); | ||
}; | ||
|
||
$scope.cancel = function () { | ||
$modalInstance.dismiss('cancel'); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<section ng-controller="ShareCtrl"> | ||
<h4>Shares</h4> | ||
|
||
<table class="table table-striped table-hover table-condensed"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Path</th> | ||
<th>Size</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="directory in directories"> | ||
<td>{{ directory.name }}</td> | ||
<td>{{ directory.path }}</td> | ||
<td>{{ directory.sizeFormatted }}</td> | ||
<td> | ||
<button class="btn btn-danger btn-xs" type="button" title="Remove this share" | ||
ng-click="removeShareDir(directory)"> | ||
<span class="glyphicon glyphicon-remove"></span> | ||
</button> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<button type="button" class="btn btn-default btn-success" ng-click="openAddShareDirModal()"> | ||
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> | ||
Add a new directory | ||
</button> | ||
|
||
<!-- model dialog for adding a new share --> | ||
<script type="text/ng-template" id="addShareDirModal.html"> | ||
<div class="modal-header"> | ||
<h3 class="modal-title">Add a new directory</h3> | ||
</div> | ||
<div class="modal-body"> | ||
<form class="form-horizontal" ng-model-options="{ updateOn: 'blur' }"> | ||
<div class="form-group"> | ||
<label for="add_share_name" class="col-sm-3 control-label">Name</label> | ||
|
||
<div class="input-group col-sm-7"> | ||
<input id="add_share_name" type="text" class="form-control" ng-model="name"> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<label for="add_share_path" class="col-sm-3 control-label">Path</label> | ||
|
||
<div class="input-group col-sm-7"> | ||
<input id="add_share_path" type="text" class="form-control" ng-model="path"> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="modal-footer"> | ||
<button class="btn btn-primary" ng-click="ok()">Add</button> | ||
<button class="btn btn-warning" ng-click="cancel()">Cancel</button> | ||
</div> | ||
</script> | ||
</section> | ||
|
||
<hr/> | ||
|
||
<section> | ||
<h4>Configuration</h4> | ||
|
||
<form class="form-horizontal" ng-model-options="{ updateOn: 'blur' }"> | ||
<div class="form-group" ng-repeat="setting in settings" | ||
ng-class="{'has-success': setting.success, 'has-error': setting.error}"> | ||
<label for="{{ setting.key }}" class="col-sm-3 control-label">{{ setting.key }}</label> | ||
|
||
<div class="input-group col-sm-7"> | ||
<input id="{{ setting.key }}" type="{{ setting.type }}" class="form-control" ng-model="setting.value"> | ||
|
||
<div ng-show="{{ setting.suffix != undefined }}" class="input-group-addon">{{ setting.suffix }}</div> | ||
</div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-offset-3 col-sm-7"> | ||
<button type="submit" class="btn btn-default" ng-click="reset()">Reset</button> | ||
<button type="submit" class="btn btn-default btn-primary" ng-click="save()">Save</button> | ||
</div> | ||
</div> | ||
</form> | ||
</section> |