mirror of https://github.com/portainer/portainer
feat(agent): browse files
parent
5956c4db40
commit
0b8665f148
|
@ -1,34 +1,67 @@
|
||||||
angular
|
angular.module('portainer.agent').controller('HostBrowserController', [
|
||||||
.module('portainer.agent')
|
'HostBrowserService',
|
||||||
.controller('HostBrowserController', [function HostBrowserController() {
|
'Notifications',
|
||||||
|
function HostBrowserController(HostBrowserService, Notifications) {
|
||||||
|
var ctrl = this;
|
||||||
|
ctrl.state = {
|
||||||
|
path: '/'
|
||||||
|
};
|
||||||
|
|
||||||
this.isRoot=true
|
ctrl.goToParent = goToParent;
|
||||||
this.files = []
|
ctrl.browse = browse;
|
||||||
|
ctrl.renameFile = renameFile;
|
||||||
this.goToParent = goToParent;
|
ctrl.downloadFile = downloadFile;
|
||||||
this.browse = browse;
|
ctrl.deleteFile = deleteFile;
|
||||||
this.renameFile = renameFile;
|
ctrl.isRoot = isRoot;
|
||||||
this.downloadFile = downloadFile;
|
ctrl.$onInit = $onInit;
|
||||||
this.deleteFile = deleteFile;
|
|
||||||
|
|
||||||
function goToParent() {
|
function goToParent() {
|
||||||
|
getFilesForPath(parentPath(this.state.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
function browse(folderName) {
|
function isRoot() {
|
||||||
|
return ctrl.state.path === '/';
|
||||||
}
|
|
||||||
|
|
||||||
function renameFile(name, newName) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadFile(name) {
|
function browse(folder) {
|
||||||
|
getFilesForPath(buildPath(ctrl.state.path, folder));
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteFile(name) {
|
function getFilesForPath(path) {
|
||||||
|
HostBrowserService.ls(path)
|
||||||
|
.then(function onFilesLoaded(files) {
|
||||||
|
ctrl.state.path = path;
|
||||||
|
ctrl.files = files;
|
||||||
|
})
|
||||||
|
.catch(function onLoadingFailed(err) {
|
||||||
|
Notifications.error('Failure', err, 'Unable to browse');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}]);
|
function renameFile(name, newName) {}
|
||||||
|
|
||||||
|
function downloadFile(name) {}
|
||||||
|
|
||||||
|
function deleteFile(name) {}
|
||||||
|
|
||||||
|
function $onInit() {
|
||||||
|
getFilesForPath('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function parentPath(path) {
|
||||||
|
if (path.lastIndexOf('/') === 0) {
|
||||||
|
return '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
var split = _.split(path, '/');
|
||||||
|
return _.join(_.slice(split, 0, split.length - 1), '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildPath(parent, file) {
|
||||||
|
if (parent === '/') {
|
||||||
|
return parent + file;
|
||||||
|
}
|
||||||
|
return parent + '/' + file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
title-text="Host browser" title-icon="fa-file"
|
title-text="Host browser" title-icon="fa-file"
|
||||||
dataset="$ctrl.files" table-key="host_browser"
|
dataset="$ctrl.files" table-key="host_browser"
|
||||||
order-by="Dir"
|
order-by="Dir"
|
||||||
is-root="$ctrl.state.isRoot"
|
is-root="$ctrl.isRoot()"
|
||||||
go-to-parent="$ctrl.goToParent()"
|
go-to-parent="$ctrl.goToParent()"
|
||||||
browse="$ctrl.browse(name)"
|
browse="$ctrl.browse(name)"
|
||||||
rename="$ctrl.renameFile(name, newName)"
|
rename="$ctrl.renameFile(name, newName)"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
angular.module('portainer.agent').component('hostBrowser', {
|
angular.module('portainer.agent').component('hostBrowser', {
|
||||||
bindings: {},
|
|
||||||
controller: 'HostBrowserController',
|
controller: 'HostBrowserController',
|
||||||
templateUrl: 'app/agent/components/host-browser/host-browser.html'
|
templateUrl: 'app/agent/components/host-browser/host-browser.html',
|
||||||
|
bindings: {}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
angular.module('portainer.agent').factory('HostBrowserService', [
|
||||||
|
'Browse',
|
||||||
|
function HostBrowserServiceFactory(Browse) {
|
||||||
|
var service = {};
|
||||||
|
|
||||||
|
service.ls = ls;
|
||||||
|
service.get = get;
|
||||||
|
service.delete = deletePath;
|
||||||
|
service.rename = rename;
|
||||||
|
|
||||||
|
function ls(path) {
|
||||||
|
return Browse.ls({ path: path }).$promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get(path) {
|
||||||
|
return Browse.get({ path: path }).$promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function deletePath(path) {
|
||||||
|
return Browse.delete({ path: path }).$promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rename(path, newPath) {
|
||||||
|
var payload = {
|
||||||
|
CurrentFilePath: path,
|
||||||
|
NewFilePath: newPath
|
||||||
|
};
|
||||||
|
return Browse.rename({}, payload).$promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
return service;
|
||||||
|
}
|
||||||
|
]);
|
|
@ -243,6 +243,16 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var nodeBrowser = {
|
||||||
|
name: 'docker.nodes.node.browse',
|
||||||
|
url: '/browse',
|
||||||
|
views: {
|
||||||
|
'content@': {
|
||||||
|
component: 'nodeBrowserView'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var secrets = {
|
var secrets = {
|
||||||
name: 'docker.secrets',
|
name: 'docker.secrets',
|
||||||
url: '/secrets',
|
url: '/secrets',
|
||||||
|
@ -414,16 +424,7 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var host = {
|
|
||||||
name: 'docker.host',
|
|
||||||
url: '/host',
|
|
||||||
views: {
|
|
||||||
'content@': {
|
|
||||||
templateUrl: 'app/docker/views/host/host.html',
|
|
||||||
controller: 'HostController'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$stateRegistryProvider.register(configs);
|
$stateRegistryProvider.register(configs);
|
||||||
$stateRegistryProvider.register(config);
|
$stateRegistryProvider.register(config);
|
||||||
|
@ -448,6 +449,7 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
$stateRegistryProvider.register(networkCreation);
|
$stateRegistryProvider.register(networkCreation);
|
||||||
$stateRegistryProvider.register(nodes);
|
$stateRegistryProvider.register(nodes);
|
||||||
$stateRegistryProvider.register(node);
|
$stateRegistryProvider.register(node);
|
||||||
|
$stateRegistryProvider.register(nodeBrowser);
|
||||||
$stateRegistryProvider.register(secrets);
|
$stateRegistryProvider.register(secrets);
|
||||||
$stateRegistryProvider.register(secret);
|
$stateRegistryProvider.register(secret);
|
||||||
$stateRegistryProvider.register(secretCreation);
|
$stateRegistryProvider.register(secretCreation);
|
||||||
|
@ -464,5 +466,4 @@ angular.module('portainer.docker', ['portainer.app'])
|
||||||
$stateRegistryProvider.register(volume);
|
$stateRegistryProvider.register(volume);
|
||||||
$stateRegistryProvider.register(volumeBrowse);
|
$stateRegistryProvider.register(volumeBrowse);
|
||||||
$stateRegistryProvider.register(volumeCreation);
|
$stateRegistryProvider.register(volumeCreation);
|
||||||
$stateRegistryProvider.register(host);
|
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
<li class="sidebar-list" ng-if="$ctrl.swarmManagement">
|
<li class="sidebar-list" ng-if="$ctrl.swarmManagement">
|
||||||
<a ui-sref="docker.swarm" ui-sref-active="active">Swarm <span class="menu-icon fa fa-object-group fa-fw"></span></a>
|
<a ui-sref="docker.swarm" ui-sref-active="active">Swarm <span class="menu-icon fa fa-object-group fa-fw"></span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="sidebar-list" ng-if="$ctrl.isAgent">
|
|
||||||
<a ui-sref="docker.host" ui-sref-active="active">Host <span class="menu-icon fa fa-object-group fa-fw"></span></a>
|
|
||||||
</li>
|
|
||||||
<li class="sidebar-list" ng-if="$ctrl.standaloneManagement">
|
<li class="sidebar-list" ng-if="$ctrl.standaloneManagement">
|
||||||
<a ui-sref="docker.host" ui-sref-active="active">Host <span class="menu-icon fa fa-th fa-fw"></span></a>
|
<a ui-sref="docker.host" ui-sref-active="active">Host <span class="menu-icon fa fa-th fa-fw"></span></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
<rd-header>
|
<rd-header>
|
||||||
<rd-header-title title-text="Host overview">
|
<rd-header-title title-text="Host overview">
|
||||||
<a data-toggle="tooltip" title="Refresh" ui-sref="{{$ctrl.refreshUrl}}" ui-sref-opts="{reload: true}">
|
<a data-toggle="tooltip" title="Refresh" ui-sref="{{$ctrl.refreshUrl}}"
|
||||||
|
ui-sref-opts="{reload: true}">
|
||||||
<i class="fa fa-sync" aria-hidden="true"></i>
|
<i class="fa fa-sync" aria-hidden="true"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<a title="Browse" ui-sref="docker.nodes.node.browse" ng-if="$ctrl.isAgent">
|
||||||
|
Browse
|
||||||
|
</a>
|
||||||
</rd-header-title>
|
</rd-header-title>
|
||||||
<rd-header-content>Docker</rd-header-content>
|
<rd-header-content>Docker</rd-header-content>
|
||||||
</rd-header>
|
</rd-header>
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
angular.module('portainer.docker').controller('HostController', [
|
|
||||||
'$transition$',
|
|
||||||
function HostController() {
|
|
||||||
initView();
|
|
||||||
|
|
||||||
function initView() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
]);
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
angular.module('portainer.docker').controller('NodeBrowserController', [
|
||||||
|
'NodeService',
|
||||||
|
'HttpRequestHelper',
|
||||||
|
'$stateParams',
|
||||||
|
function NodeBrowserController(NodeService, HttpRequestHelper, $stateParams) {
|
||||||
|
var ctrl = this;
|
||||||
|
|
||||||
|
ctrl.$onInit = $onInit;
|
||||||
|
|
||||||
|
function $onInit() {
|
||||||
|
ctrl.nodeId = $stateParams.id;
|
||||||
|
NodeService.node(ctrl.nodeId).then(function onNodeLoaded(node) {
|
||||||
|
HttpRequestHelper.setPortainerAgentTargetHeader(node.Hostname);
|
||||||
|
ctrl.node = node;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
|
@ -1,7 +1,7 @@
|
||||||
<rd-header>
|
<rd-header>
|
||||||
<rd-header-title title-text="Host"></rd-header-title>
|
<rd-header-title title-text="Node Browser"></rd-header-title>
|
||||||
<rd-header-content>
|
<rd-header-content>
|
||||||
Host
|
<a ui-sref="docker.volumes">Nodes</a> > <a ui-sref="docker.nodes.nodes({ id: $ctrl.nodeId })">{{ $ctrl.node.Hostname }}</a> > browse
|
||||||
</rd-header-content>
|
</rd-header-content>
|
||||||
</rd-header>
|
</rd-header>
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
angular.module('portainer.docker').component('nodeBrowserView', {
|
||||||
|
templateUrl: 'app/docker/views/nodes/node-browser/node-browser.html',
|
||||||
|
controller: 'NodeBrowserController'
|
||||||
|
});
|
Loading…
Reference in New Issue