mirror of
https://github.com/portainer/portainer.git
synced 2025-08-04 13:25:26 +02:00
feat(docker/networks): migrate networks datatable to React [EE-4670] (#10351)
Co-authored-by: LP B <xAt0mZ@users.noreply.github.com>
This commit is contained in:
parent
0dc1805881
commit
b933bee95e
17 changed files with 333 additions and 440 deletions
79
app/docker/models/network.ts
Normal file
79
app/docker/models/network.ts
Normal file
|
@ -0,0 +1,79 @@
|
|||
import { IPAM, Network, NetworkContainer } from 'docker-types/generated/1.41';
|
||||
|
||||
import { ResourceControlViewModel } from '@/react/portainer/access-control/models/ResourceControlViewModel';
|
||||
import { IResource } from '@/react/docker/components/datatable/createOwnershipColumn';
|
||||
import { PortainerMetadata } from '@/react/docker/types';
|
||||
|
||||
export class NetworkViewModel implements IResource {
|
||||
Id: string;
|
||||
|
||||
Name: string;
|
||||
|
||||
Scope: string;
|
||||
|
||||
Driver: string;
|
||||
|
||||
Attachable: boolean;
|
||||
|
||||
Internal: boolean;
|
||||
|
||||
IPAM?: IPAM;
|
||||
|
||||
Containers?: Record<string, NetworkContainer>;
|
||||
|
||||
Options?: Record<string, string>;
|
||||
|
||||
Ingress: boolean;
|
||||
|
||||
Labels: Record<string, string>;
|
||||
|
||||
StackName?: string;
|
||||
|
||||
NodeName?: string;
|
||||
|
||||
ConfigFrom?: { Network: string };
|
||||
|
||||
ConfigOnly?: boolean;
|
||||
|
||||
ResourceControl?: ResourceControlViewModel;
|
||||
|
||||
constructor(
|
||||
data: Network & {
|
||||
Portainer?: PortainerMetadata;
|
||||
ConfigFrom?: { Network: string };
|
||||
ConfigOnly?: boolean;
|
||||
}
|
||||
) {
|
||||
this.Id = data.Id || '';
|
||||
this.Name = data.Name || '';
|
||||
this.Scope = data.Scope || '';
|
||||
this.Driver = data.Driver || '';
|
||||
this.Attachable = data.Attachable || false;
|
||||
this.Internal = data.Internal || false;
|
||||
this.IPAM = data.IPAM;
|
||||
this.Containers = data.Containers;
|
||||
this.Options = data.Options;
|
||||
this.Ingress = data.Ingress || false;
|
||||
|
||||
this.Labels = data.Labels || {};
|
||||
if (this.Labels && this.Labels['com.docker.compose.project']) {
|
||||
this.StackName = this.Labels['com.docker.compose.project'];
|
||||
} else if (this.Labels && this.Labels['com.docker.stack.namespace']) {
|
||||
this.StackName = this.Labels['com.docker.stack.namespace'];
|
||||
}
|
||||
|
||||
if (data.Portainer) {
|
||||
if (data.Portainer.ResourceControl) {
|
||||
this.ResourceControl = new ResourceControlViewModel(
|
||||
data.Portainer.ResourceControl
|
||||
);
|
||||
}
|
||||
if (data.Portainer.Agent && data.Portainer.Agent.NodeName) {
|
||||
this.NodeName = data.Portainer.Agent.NodeName;
|
||||
}
|
||||
}
|
||||
|
||||
this.ConfigFrom = data.ConfigFrom;
|
||||
this.ConfigOnly = data.ConfigOnly;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue