1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

chore(project): add prettier for code format (#3645)

* chore(project): install prettier and lint-staged

* chore(project): apply prettier to html too

* chore(project): git ignore eslintcache

* chore(project): add a comment about format script

* chore(prettier): update printWidth

* chore(prettier): remove useTabs option

* chore(prettier): add HTML validation

* refactor(prettier): fix closing tags

* feat(prettier): define angular parser for html templates

* style(prettier): run prettier on codebase

Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
Chaim Lev-Ari 2020-04-11 00:54:53 +03:00 committed by GitHub
parent 6663073be1
commit cf5056d9c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
714 changed files with 31228 additions and 28305 deletions

View file

@ -1,12 +1,15 @@
import _ from 'lodash-es';
angular.module('portainer.agent').controller('HostBrowserController', [
'HostBrowserService', 'Notifications', 'FileSaver', 'ModalService',
'HostBrowserService',
'Notifications',
'FileSaver',
'ModalService',
function HostBrowserController(HostBrowserService, Notifications, FileSaver, ModalService) {
var ctrl = this;
var ROOT_PATH = '/host';
ctrl.state = {
path: ROOT_PATH
path: ROOT_PATH,
};
ctrl.goToParent = goToParent;
@ -21,7 +24,7 @@ angular.module('portainer.agent').controller('HostBrowserController', [
function getRelativePath(path) {
path = path || ctrl.state.path;
var rootPathRegex = new RegExp('^' + ROOT_PATH + '\/?');
var rootPathRegex = new RegExp('^' + ROOT_PATH + '/?');
var relativePath = path.replace(rootPathRegex, '/');
return relativePath;
}
@ -71,7 +74,7 @@ angular.module('portainer.agent').controller('HostBrowserController', [
HostBrowserService.get(filePath)
.then(function onFileReceived(data) {
var downloadData = new Blob([data.file], {
type: 'text/plain;charset=utf-8'
type: 'text/plain;charset=utf-8',
});
FileSaver.saveAs(downloadData, file);
})
@ -83,15 +86,12 @@ angular.module('portainer.agent').controller('HostBrowserController', [
function confirmDeleteFile(name) {
var filePath = buildPath(ctrl.state.path, name);
ModalService.confirmDeletion(
'Are you sure that you want to delete ' + getRelativePath(filePath) + ' ?',
function onConfirm(confirmed) {
if (!confirmed) {
return;
}
return deleteFile(filePath);
ModalService.confirmDeletion('Are you sure that you want to delete ' + getRelativePath(filePath) + ' ?', function onConfirm(confirmed) {
if (!confirmed) {
return;
}
);
return deleteFile(filePath);
});
}
function deleteFile(path) {
@ -145,5 +145,5 @@ angular.module('portainer.agent').controller('HostBrowserController', [
function refreshList() {
getFilesForPath(ctrl.state.path);
}
}
},
]);

View file

@ -1,6 +1,8 @@
<files-datatable
title-text="Host browser - {{$ctrl.getRelativePath()}}" title-icon="fa-file"
dataset="$ctrl.files" table-key="host_browser"
title-text="Host browser - {{ $ctrl.getRelativePath() }}"
title-icon="fa-file"
dataset="$ctrl.files"
table-key="host_browser"
order-by="Dir"
is-root="$ctrl.isRoot()"
go-to-parent="$ctrl.goToParent()"
@ -8,9 +10,7 @@
rename="$ctrl.renameFile(name, newName)"
download="$ctrl.downloadFile(name)"
delete="$ctrl.deleteFile(name)"
is-upload-allowed="true"
on-file-selected-for-upload="$ctrl.onFileSelectedForUpload"
on-file-selected-for-upload="($ctrl.onFileSelectedForUpload)"
>
</files-datatable>

View file

@ -1,5 +1,5 @@
angular.module('portainer.agent').component('hostBrowser', {
controller: 'HostBrowserController',
templateUrl: './host-browser.html',
bindings: {}
bindings: {},
});