fix(edge): fix edge views (#4184)

* fix(edge): add ngInject

* feat(edge): init edge job model
pull/4192/head
Chaim Lev-Ari 2020-08-11 00:51:21 +03:00 committed by GitHub
parent 134f2f1532
commit c439bc56ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 23 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import angular from 'angular'; import angular from 'angular';
export class AssociatedEndpointsDatatableController { export class AssociatedEndpointsDatatableController {
/* @ngInject */
constructor($scope, $controller, DatatableService, PaginationService) { constructor($scope, $controller, DatatableService, PaginationService) {
this.extendGenericController($controller, $scope); this.extendGenericController($controller, $scope);
this.DatatableService = DatatableService; this.DatatableService = DatatableService;

View File

@ -33,8 +33,6 @@ export class EdgeJobFormController {
// see https://regexr.com/573i2 // see https://regexr.com/573i2
this.cronRegex = /(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ){4,6}((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*))/; this.cronRegex = /(@(annually|yearly|monthly|weekly|daily|hourly|reboot))|(@every (\d+(ns|us|µs|ms|s|m|h))+)|((((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*) ){4,6}((\d+,)+\d+|(\d+(\/|-)\d+)|\d+|\*))/;
this.onChangeModel(this.model);
this.action = this.action.bind(this); this.action = this.action.bind(this);
this.editorUpdate = this.editorUpdate.bind(this); this.editorUpdate = this.editorUpdate.bind(this);
this.associateEndpoint = this.associateEndpoint.bind(this); this.associateEndpoint = this.associateEndpoint.bind(this);
@ -85,6 +83,10 @@ export class EdgeJobFormController {
dissociateEndpoint(endpoint) { dissociateEndpoint(endpoint) {
this.model.Endpoints = _.filter(this.model.Endpoints, (id) => id !== endpoint.Id); this.model.Endpoints = _.filter(this.model.Endpoints, (id) => id !== endpoint.Id);
} }
$onInit() {
this.onChangeModel(this.model);
}
} }
function cronToDatetime(cron, defaultTime = moment()) { function cronToDatetime(cron, defaultTime = moment()) {

View File

@ -1,6 +1,7 @@
import angular from 'angular'; import angular from 'angular';
export class EdgeStackEndpointsDatatableController { export class EdgeStackEndpointsDatatableController {
/* @ngInject */
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;

View File

@ -1,4 +1,5 @@
export class EditEdgeStackFormController { export class EditEdgeStackFormController {
/* @ngInject */
constructor() { constructor() {
this.editorUpdate = this.editorUpdate.bind(this); this.editorUpdate = this.editorUpdate.bind(this);
} }

View File

@ -1,6 +1,7 @@
import angular from 'angular'; import angular from 'angular';
export class EdgeGroupsDatatableController { export class EdgeGroupsDatatableController {
/* @ngInject */
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 }));

View File

@ -1,9 +1,19 @@
export class CreateEdgeJobViewController { export class CreateEdgeJobViewController {
/* @ngInject */
constructor($async, $q, $state, EdgeJobService, GroupService, Notifications, TagService) { constructor($async, $q, $state, EdgeJobService, GroupService, Notifications, TagService) {
this.state = { this.state = {
actionInProgress: false, actionInProgress: false,
}; };
this.model = {
Name: '',
Recurring: false,
CronExpression: '',
Endpoints: [],
FileContent: '',
File: null,
};
this.$async = $async; this.$async = $async;
this.$q = $q; this.$q = $q;
this.$state = $state; this.$state = $state;
@ -43,15 +53,6 @@ export class CreateEdgeJobViewController {
} }
async $onInit() { async $onInit() {
this.model = {
Name: '',
Recurring: false,
CronExpression: '',
Endpoints: [],
FileContent: '',
File: null,
};
try { try {
const [groups, tags] = await Promise.all([this.GroupService.groups(), this.TagService.tags()]); const [groups, tags] = await Promise.all([this.GroupService.groups(), this.TagService.tags()]);
this.groups = groups; this.groups = groups;

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
export class EdgeJobController { export class EdgeJobController {
/* @ngInject */
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,

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
export class EdgeJobsViewController { export class EdgeJobsViewController {
/* @ngInject */
constructor($async, $state, EdgeJobService, ModalService, Notifications) { constructor($async, $state, EdgeJobService, ModalService, Notifications) {
this.$async = $async; this.$async = $async;
this.$state = $state; this.$state = $state;

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
export class CreateEdgeStackViewController { export class CreateEdgeStackViewController {
/* @ngInject */
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 });

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
export class EdgeStacksViewController { export class EdgeStacksViewController {
/* @ngInject */
constructor($state, Notifications, EdgeStackService, $scope, $async) { constructor($state, Notifications, EdgeStackService, $scope, $async) {
this.$state = $state; this.$state = $state;
this.Notifications = Notifications; this.Notifications = Notifications;

View File

@ -1,6 +1,7 @@
import _ from 'lodash-es'; import _ from 'lodash-es';
export class EditEdgeStackViewController { export class EditEdgeStackViewController {
/* @ngInject */
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;