mirror of https://github.com/portainer/portainer
refactor(agent): node selector (#4084)
* refactor(agent): rename files * refactor(agent): replace controller with regular export * refactor(agent): replace function with class * refactor(agent): replace promise with async * refactor(agent): rename main filepull/4073/head
parent
67069547b8
commit
3a33365133
|
@ -1,6 +1,10 @@
|
||||||
|
import angular from 'angular';
|
||||||
|
|
||||||
|
import { NodeSelectorController } from './nodeSelectorController';
|
||||||
|
|
||||||
angular.module('portainer.agent').component('nodeSelector', {
|
angular.module('portainer.agent').component('nodeSelector', {
|
||||||
templateUrl: './nodeSelector.html',
|
templateUrl: './nodeSelector.html',
|
||||||
controller: 'NodeSelectorController',
|
controller: NodeSelectorController,
|
||||||
bindings: {
|
bindings: {
|
||||||
model: '=',
|
model: '=',
|
||||||
},
|
},
|
|
@ -1,20 +1,17 @@
|
||||||
angular.module('portainer.agent').controller('NodeSelectorController', [
|
export class NodeSelectorController {
|
||||||
'AgentService',
|
constructor(AgentService, Notifications) {
|
||||||
'Notifications',
|
Object.assign(this, { AgentService, Notifications });
|
||||||
function (AgentService, Notifications) {
|
}
|
||||||
var ctrl = this;
|
|
||||||
|
|
||||||
this.$onInit = function () {
|
async $onInit() {
|
||||||
AgentService.agents()
|
try {
|
||||||
.then(function success(data) {
|
const agents = await this.AgentService.agents();
|
||||||
ctrl.agents = data;
|
this.agents = agents;
|
||||||
if (!ctrl.model) {
|
if (!this.model) {
|
||||||
ctrl.model = data[0].NodeName;
|
this.model = agents[0].NodeName;
|
||||||
}
|
}
|
||||||
})
|
} catch (err) {
|
||||||
.catch(function error(err) {
|
this.Notifications.error('Failure', err, 'Unable to load agents');
|
||||||
Notifications.error('Failure', err, 'Unable to load agents');
|
}
|
||||||
});
|
}
|
||||||
};
|
}
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
Loading…
Reference in New Issue