1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

refactor(edge-compute): enforce es6 good practices (#3961)

* refactor(edge-groups): use es6 imports

* refactor(edge-jobs): es6 imports

* refactor(edge-stacks): use es6 imports

* refactor(edge-compute): use es6 imports in components

* refactor(edge-compute): use named imports
This commit is contained in:
Chaim Lev-Ari 2020-07-06 10:35:13 +03:00 committed by GitHub
parent af6bea5acc
commit 42aa8ceb00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 99 additions and 115 deletions

View file

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
class AssociatedEndpointsDatatableController { export class AssociatedEndpointsDatatableController {
constructor($scope, $controller, DatatableService, PaginationService) { constructor($scope, $controller, DatatableService, PaginationService) {
this.extendGenericController($controller, $scope); this.extendGenericController($controller, $scope);
this.DatatableService = DatatableService; this.DatatableService = DatatableService;
@ -98,6 +98,3 @@ class AssociatedEndpointsDatatableController {
}); });
} }
} }
angular.module('portainer.edge').controller('AssociatedEndpointsDatatableController', AssociatedEndpointsDatatableController);
export default AssociatedEndpointsDatatableController;

View file

@ -1,6 +1,10 @@
import angular from 'angular';
import { AssociatedEndpointsDatatableController } from './associatedEndpointsDatatableController';
angular.module('portainer.edge').component('associatedEndpointsDatatable', { angular.module('portainer.edge').component('associatedEndpointsDatatable', {
templateUrl: './associatedEndpointsDatatable.html', templateUrl: './associatedEndpointsDatatable.html',
controller: 'AssociatedEndpointsDatatableController', controller: AssociatedEndpointsDatatableController,
bindings: { bindings: {
titleText: '@', titleText: '@',
titleIcon: '@', titleIcon: '@',

View file

@ -1,5 +1,7 @@
import angular from 'angular';
angular.module('portainer.edge').component('edgeGroupsSelector', { angular.module('portainer.edge').component('edgeGroupsSelector', {
templateUrl: './edge-groups-selector.html', templateUrl: './edgeGroupsSelector.html',
bindings: { bindings: {
model: '=', model: '=',
items: '<', items: '<',

View file

@ -1,8 +1,7 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
import moment from 'moment'; import moment from 'moment';
class EdgeJobFormController { export class EdgeJobFormController {
/* @ngInject */ /* @ngInject */
constructor() { constructor() {
this.state = { this.state = {
@ -102,6 +101,3 @@ function datetimeToCron(datetime) {
var date = moment(datetime); var date = moment(datetime);
return [date.minutes(), date.hours(), date.date(), date.month() + 1, '*'].join(' '); return [date.minutes(), date.hours(), date.date(), date.month() + 1, '*'].join(' ');
} }
angular.module('portainer.edge').controller('EdgeJobFormController', EdgeJobFormController);
export default EdgeJobFormController;

View file

@ -1,4 +1,6 @@
import EdgeJobFormController from './edgeJobFormController'; import angular from 'angular';
import { EdgeJobFormController } from './edgeJobFormController';
angular.module('portainer.edge').component('edgeJobForm', { angular.module('portainer.edge').component('edgeJobForm', {
templateUrl: './edgeJobForm.html', templateUrl: './edgeJobForm.html',

View file

@ -1,6 +1,7 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
export default class EdgeJobResultsDatatableController { export class EdgeJobResultsDatatableController {
/* @ngInject */ /* @ngInject */
constructor($controller, $scope, $state) { constructor($controller, $scope, $state) {
this.$state = $state; this.$state = $state;

View file

@ -1,5 +1,6 @@
import angular from 'angular'; import angular from 'angular';
import EdgeJobResultsDatatableController from './edgeJobResultsDatatableController';
import { EdgeJobResultsDatatableController } from './edgeJobResultsDatatableController';
import './edgeJobResultsDatatable.css'; import './edgeJobResultsDatatable.css';
angular.module('portainer.edge').component('edgeJobResultsDatatable', { angular.module('portainer.edge').component('edgeJobResultsDatatable', {

View file

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
class EdgeStackEndpointsDatatableController { export class EdgeStackEndpointsDatatableController {
constructor($async, $scope, $controller, DatatableService, PaginationService, Notifications) { constructor($async, $scope, $controller, DatatableService, PaginationService, Notifications) {
this.extendGenericController($controller, $scope); this.extendGenericController($controller, $scope);
this.DatatableService = DatatableService; this.DatatableService = DatatableService;
@ -106,6 +106,3 @@ class EdgeStackEndpointsDatatableController {
} }
} }
} }
angular.module('portainer.edge').controller('EdgeStackEndpointsDatatableController', EdgeStackEndpointsDatatableController);
export default EdgeStackEndpointsDatatableController;

View file

@ -1,6 +1,10 @@
import angular from 'angular';
import { EdgeStackEndpointsDatatableController } from './edgeStackEndpointsDatatableController';
angular.module('portainer.edge').component('edgeStackEndpointsDatatable', { angular.module('portainer.edge').component('edgeStackEndpointsDatatable', {
templateUrl: './edgeStackEndpointsDatatable.html', templateUrl: './edgeStackEndpointsDatatable.html',
controller: 'EdgeStackEndpointsDatatableController', controller: EdgeStackEndpointsDatatableController,
bindings: { bindings: {
titleText: '@', titleText: '@',
titleIcon: '@', titleIcon: '@',

View file

@ -1,12 +1,10 @@
import angular from 'angular';
const statusMap = { const statusMap = {
1: 'ok', 1: 'ok',
2: 'error', 2: 'error',
3: 'acknowledged', 3: 'acknowledged',
}; };
class EdgeStackStatusController { export class EdgeStackStatusController {
$onChanges({ stackStatus }) { $onChanges({ stackStatus }) {
if (!stackStatus || !stackStatus.currentValue) { if (!stackStatus || !stackStatus.currentValue) {
return; return;
@ -20,6 +18,3 @@ class EdgeStackStatusController {
this.status = aggregateStatus; this.status = aggregateStatus;
} }
} }
angular.module('portainer.edge').controller('EdgeStackStatusController', EdgeStackStatusController);
export default EdgeStackStatusController;

View file

@ -1,10 +1,11 @@
import angular from 'angular'; import angular from 'angular';
import { EdgeStackStatusController } from './edgeStackStatusController';
import './edgeStackStatus.css'; import './edgeStackStatus.css';
angular.module('portainer.edge').component('edgeStackStatus', { angular.module('portainer.edge').component('edgeStackStatus', {
templateUrl: './edgeStackStatus.html', templateUrl: './edgeStackStatus.html',
controller: 'EdgeStackStatusController', controller: EdgeStackStatusController,
bindings: { bindings: {
stackStatus: '<', stackStatus: '<',
}, },

View file

@ -1,3 +1,5 @@
import angular from 'angular';
angular.module('portainer.edge').component('edgeStacksDatatable', { angular.module('portainer.edge').component('edgeStacksDatatable', {
templateUrl: './edgeStacksDatatable.html', templateUrl: './edgeStacksDatatable.html',
controller: 'GenericDatatableController', controller: 'GenericDatatableController',

View file

@ -1,6 +1,4 @@
import angular from 'angular'; export class EditEdgeStackFormController {
class EditEdgeStackFormController {
constructor() { constructor() {
this.editorUpdate = this.editorUpdate.bind(this); this.editorUpdate = this.editorUpdate.bind(this);
} }
@ -9,6 +7,3 @@ class EditEdgeStackFormController {
this.model.StackFileContent = cm.getValue(); this.model.StackFileContent = cm.getValue();
} }
} }
angular.module('portainer.edge').controller('EditEdgeStackFormController', EditEdgeStackFormController);
export default EditEdgeStackFormController;

View file

@ -1,6 +1,10 @@
import angular from 'angular';
import { EditEdgeStackFormController } from './editEdgeStackFormController';
angular.module('portainer.edge').component('editEdgeStackForm', { angular.module('portainer.edge').component('editEdgeStackForm', {
templateUrl: './editEdgeStackForm.html', templateUrl: './editEdgeStackForm.html',
controller: 'EditEdgeStackFormController', controller: EditEdgeStackFormController,
bindings: { bindings: {
model: '<', model: '<',
actionInProgress: '<', actionInProgress: '<',

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EdgeGroupFormController { export class EdgeGroupFormController {
/* @ngInject */ /* @ngInject */
constructor(EndpointService, $async, $scope) { constructor(EndpointService, $async, $scope) {
this.EndpointService = EndpointService; this.EndpointService = EndpointService;
@ -59,6 +58,3 @@ class EdgeGroupFormController {
this.endpoints.state.totalCount = totalCount; this.endpoints.state.totalCount = totalCount;
} }
} }
angular.module('portainer.edge').controller('EdgeGroupFormController', EdgeGroupFormController);
export default EdgeGroupFormController;

View file

@ -1,6 +1,10 @@
import angular from 'angular';
import { EdgeGroupFormController } from './groupFormController';
angular.module('portainer.edge').component('edgeGroupForm', { angular.module('portainer.edge').component('edgeGroupForm', {
templateUrl: './groupForm.html', templateUrl: './groupForm.html',
controller: 'EdgeGroupFormController', controller: EdgeGroupFormController,
bindings: { bindings: {
model: '<', model: '<',
groups: '<', groups: '<',

View file

@ -1,6 +1,6 @@
import angular from 'angular'; import angular from 'angular';
class EdgeGroupsDatatableController { export class EdgeGroupsDatatableController {
constructor($scope, $controller) { constructor($scope, $controller) {
const allowSelection = this.allowSelection; const allowSelection = this.allowSelection;
angular.extend(this, $controller('GenericDatatableController', { $scope: $scope })); angular.extend(this, $controller('GenericDatatableController', { $scope: $scope }));
@ -14,6 +14,3 @@ class EdgeGroupsDatatableController {
return !item.HasEdgeStack; return !item.HasEdgeStack;
} }
} }
angular.module('portainer.edge').controller('EdgeGroupsDatatableController', EdgeGroupsDatatableController);
export default EdgeGroupsDatatableController;

View file

@ -1,8 +1,10 @@
import angular from 'angular'; import angular from 'angular';
import { EdgeGroupsDatatableController } from './groupsDatatableController';
angular.module('portainer.edge').component('edgeGroupsDatatable', { angular.module('portainer.edge').component('edgeGroupsDatatable', {
templateUrl: './groupsDatatable.html', templateUrl: './groupsDatatable.html',
controller: 'EdgeGroupsDatatableController', controller: EdgeGroupsDatatableController,
bindings: { bindings: {
dataset: '<', dataset: '<',
titleIcon: '@', titleIcon: '@',

View file

@ -1,6 +1,4 @@
import angular from 'angular'; export class CreateEdgeGroupController {
class CreateEdgeGroupController {
/* @ngInject */ /* @ngInject */
constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async) { constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async) {
this.EdgeGroupService = EdgeGroupService; this.EdgeGroupService = EdgeGroupService;
@ -51,6 +49,3 @@ class CreateEdgeGroupController {
} }
} }
} }
angular.module('portainer.edge').controller('CreateEdgeGroupController', CreateEdgeGroupController);
export default CreateEdgeGroupController;

View file

@ -0,0 +1,8 @@
import angular from 'angular';
import { CreateEdgeGroupController } from './createEdgeGroupViewController';
angular.module('portainer.edge').component('createEdgeGroupView', {
templateUrl: './createEdgeGroupView.html',
controller: CreateEdgeGroupController,
});

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EdgeGroupsController { export class EdgeGroupsController {
/* @ngInject */ /* @ngInject */
constructor($async, $state, EdgeGroupService, Notifications) { constructor($async, $state, EdgeGroupService, Notifications) {
this.$async = $async; this.$async = $async;
@ -41,5 +40,3 @@ class EdgeGroupsController {
this.$state.reload(); this.$state.reload();
} }
} }
angular.module('portainer.edge').controller('EdgeGroupsController', EdgeGroupsController);

View file

@ -1,6 +1,8 @@
import angular from 'angular'; import angular from 'angular';
import { EdgeGroupsController } from './edgeGroupsViewController';
angular.module('portainer.edge').component('edgeGroupsView', { angular.module('portainer.edge').component('edgeGroupsView', {
templateUrl: './edgeGroupsView.html', templateUrl: './edgeGroupsView.html',
controller: 'EdgeGroupsController', controller: EdgeGroupsController,
}); });

View file

@ -1,6 +1,4 @@
import angular from 'angular'; export class EditEdgeGroupController {
class EditEdgeGroupController {
/* @ngInject */ /* @ngInject */
constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async, EndpointService, EndpointHelper) { constructor(EdgeGroupService, GroupService, TagService, Notifications, $state, $async, EndpointService, EndpointHelper) {
this.EdgeGroupService = EdgeGroupService; this.EdgeGroupService = EdgeGroupService;
@ -51,6 +49,3 @@ class EditEdgeGroupController {
} }
} }
} }
angular.module('portainer.edge').controller('EditEdgeGroupController', EditEdgeGroupController);
export default EditEdgeGroupController;

View file

@ -0,0 +1,8 @@
import angular from 'angular';
import { EditEdgeGroupController } from './editEdgeGroupViewController';
angular.module('portainer.edge').component('editEdgeGroupView', {
templateUrl: './editEdgeGroupView.html',
controller: EditEdgeGroupController,
});

View file

@ -1,6 +1,4 @@
import angular from 'angular'; export class CreateEdgeJobViewController {
class CreateEdgeJobController {
constructor($async, $q, $state, EdgeJobService, GroupService, Notifications, TagService) { constructor($async, $q, $state, EdgeJobService, GroupService, Notifications, TagService) {
this.state = { this.state = {
actionInProgress: false, actionInProgress: false,
@ -63,6 +61,3 @@ class CreateEdgeJobController {
} }
} }
} }
angular.module('portainer.edge').controller('CreateEdgeJobController', CreateEdgeJobController);
export default CreateEdgeJobController;

View file

@ -1,5 +1,5 @@
import angular from 'angular'; import angular from 'angular';
import CreateEdgeJobViewController from './createEdgeJobViewController'; import { CreateEdgeJobViewController } from './createEdgeJobViewController';
angular.module('portainer.edge').component('createEdgeJobView', { angular.module('portainer.edge').component('createEdgeJobView', {
templateUrl: './createEdgeJobView.html', templateUrl: './createEdgeJobView.html',

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EdgeJobController { export class EdgeJobController {
constructor($async, $q, $state, EdgeJobService, EndpointService, FileSaver, GroupService, HostBrowserService, Notifications, TagService) { constructor($async, $q, $state, EdgeJobService, EndpointService, FileSaver, GroupService, HostBrowserService, Notifications, TagService) {
this.state = { this.state = {
actionInProgress: false, actionInProgress: false,
@ -154,6 +153,3 @@ class EdgeJobController {
} }
} }
} }
angular.module('portainer.edge').controller('EdgeJobController', EdgeJobController);
export default EdgeJobController;

View file

@ -1,5 +1,5 @@
import angular from 'angular'; import angular from 'angular';
import EdgeJobController from './edgeJobController'; import { EdgeJobController } from './edgeJobController';
angular.module('portainer.edge').component('edgeJobView', { angular.module('portainer.edge').component('edgeJobView', {
templateUrl: './edgeJob.html', templateUrl: './edgeJob.html',

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EdgeJobsController { export class EdgeJobsViewController {
constructor($async, $state, EdgeJobService, ModalService, Notifications) { constructor($async, $state, EdgeJobService, ModalService, Notifications) {
this.$async = $async; this.$async = $async;
this.$state = $state; this.$state = $state;
@ -51,6 +50,3 @@ class EdgeJobsController {
} }
} }
} }
angular.module('portainer.edge').controller('EdgeJobsController', EdgeJobsController);
export default EdgeJobsController;

View file

@ -1,5 +1,5 @@
import angular from 'angular'; import angular from 'angular';
import EdgeJobsViewController from './edgeJobsViewController'; import { EdgeJobsViewController } from './edgeJobsViewController';
angular.module('portainer.edge').component('edgeJobsView', { angular.module('portainer.edge').component('edgeJobsView', {
templateUrl: './edgeJobsView.html', templateUrl: './edgeJobsView.html',

View file

@ -1,4 +0,0 @@
angular.module('portainer.edge').component('createEdgeStackView', {
templateUrl: './createEdgeStackView.html',
controller: 'CreateEdgeStackViewController',
});

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class CreateEdgeStackViewController { export class CreateEdgeStackViewController {
constructor($state, EdgeStackService, EdgeGroupService, EdgeTemplateService, Notifications, FormHelper, $async) { constructor($state, EdgeStackService, EdgeGroupService, EdgeTemplateService, Notifications, FormHelper, $async) {
Object.assign(this, { $state, EdgeStackService, EdgeGroupService, EdgeTemplateService, Notifications, FormHelper, $async }); Object.assign(this, { $state, EdgeStackService, EdgeGroupService, EdgeTemplateService, Notifications, FormHelper, $async });
@ -151,6 +150,3 @@ class CreateEdgeStackViewController {
this.formValues.StackFileContent = cm.getValue(); this.formValues.StackFileContent = cm.getValue();
} }
} }
angular.module('portainer.edge').controller('CreateEdgeStackViewController', CreateEdgeStackViewController);
export default CreateEdgeStackViewController;

View file

@ -0,0 +1,8 @@
import angular from 'angular';
import { CreateEdgeStackViewController } from './createEdgeStackViewController';
angular.module('portainer.edge').component('createEdgeStackView', {
templateUrl: './createEdgeStackView.html',
controller: CreateEdgeStackViewController,
});

View file

@ -1,4 +0,0 @@
angular.module('portainer.edge').component('edgeStacksView', {
templateUrl: './edgeStacksView.html',
controller: 'EdgeStacksViewController',
});

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EdgeStacksViewController { export class EdgeStacksViewController {
constructor($state, Notifications, EdgeStackService, $scope, $async) { constructor($state, Notifications, EdgeStackService, $scope, $async) {
this.$state = $state; this.$state = $state;
this.Notifications = Notifications; this.Notifications = Notifications;
@ -47,6 +46,3 @@ class EdgeStacksViewController {
} }
} }
} }
angular.module('portainer.edge').controller('EdgeStacksViewController', EdgeStacksViewController);
export default EdgeStacksViewController;

View file

@ -0,0 +1,8 @@
import angular from 'angular';
import { EdgeStacksViewController } from './edgeStacksViewController';
angular.module('portainer.edge').component('edgeStacksView', {
templateUrl: './edgeStacksView.html',
controller: EdgeStacksViewController,
});

View file

@ -1,4 +0,0 @@
angular.module('portainer.edge').component('editEdgeStackView', {
templateUrl: './editEdgeStackView.html',
controller: 'EditEdgeStackViewController',
});

View file

@ -1,7 +1,6 @@
import angular from 'angular';
import _ from 'lodash-es'; import _ from 'lodash-es';
class EditEdgeStackViewController { export class EditEdgeStackViewController {
constructor($async, $state, EdgeGroupService, EdgeStackService, EndpointService, Notifications) { constructor($async, $state, EdgeGroupService, EdgeStackService, EndpointService, Notifications) {
this.$async = $async; this.$async = $async;
this.$state = $state; this.$state = $state;
@ -91,6 +90,3 @@ class EditEdgeStackViewController {
} }
} }
} }
angular.module('portainer.edge').controller('EditEdgeStackViewController', EditEdgeStackViewController);
export default EditEdgeStackViewController;

View file

@ -0,0 +1,8 @@
import angular from 'angular';
import { EditEdgeStackViewController } from './editEdgeStackViewController';
angular.module('portainer.edge').component('editEdgeStackView', {
templateUrl: './editEdgeStackView.html',
controller: EditEdgeStackViewController,
});

View file

@ -1,4 +0,0 @@
angular.module('portainer.edge').component('createEdgeGroupView', {
templateUrl: './createEdgeGroupView.html',
controller: 'CreateEdgeGroupController',
});

View file

@ -1,4 +0,0 @@
angular.module('portainer.edge').component('editEdgeGroupView', {
templateUrl: './editEdgeGroupView.html',
controller: 'EditEdgeGroupController',
});