1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 06:19:41 +02:00
portainer/app/agent/components/node-selector/nodeSelectorController.js
Chaim Lev-Ari 3a33365133
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 file
2020-07-23 06:30:42 +12:00

17 lines
438 B
JavaScript

export class NodeSelectorController {
constructor(AgentService, Notifications) {
Object.assign(this, { AgentService, Notifications });
}
async $onInit() {
try {
const agents = await this.AgentService.agents();
this.agents = agents;
if (!this.model) {
this.model = agents[0].NodeName;
}
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to load agents');
}
}
}