-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathautonomous_database.js
162 lines (149 loc) · 6.51 KB
/
autonomous_database.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
** Copyright (c) 2020, Oracle and/or its affiliates.
** Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
*/
console.info('Loaded Designer AutonomousDatabase View Javascript');
/*
** Define AutonomousDatabase View Artifact Class
*/
class AutonomousDatabaseView extends OkitDesignerArtefactView {
constructor(artefact=null, json_view) {
super(artefact, json_view);
}
get parent_id() {
let subnet = this.getJsonView().getSubnet(this.artefact.subnet_id);
if (subnet && subnet.compartment_id === this.artefact.compartment_id) {
console.info('Using Subnet as parent');
return this.subnet_id;
} else {
console.info('Using Compartment as parent');
return this.compartment_id;
}
}
getParent() {
return this.getJsonView().getSubnet(this.parent_id) ? this.getJsonView().getSubnet(this.parent_id) : this.getJsonView().getCompartment(this.parent_id);
}
getParentId() {
return this.parent_id;
}
/*
** Clone Functionality
*/
clone() {
return new AutonomousDatabaseView(this.artefact, this.getJsonView());
}
/*
** SVG Processing
*/
// Additional draw Processing
draw() {
console.group('Drawing ' + this.getArtifactReference() + ' : ' + this.getArtefact().id + ' [' + this.parent_id + ']');
let svg = super.draw();
/*
** Add Properties Load Event to created svg. We require the definition of the local variable "me" so that it can
** be used in the function dur to the fact that using "this" in the function will refer to the function not the
** Artifact.
*/
// Get Inner Rect to attach Connectors
let rect = svg.select("rect[id='" + safeId(this.id) + "']");
if (rect && rect.node()) {
let boundingClientRect = rect.node().getBoundingClientRect();
// Add Connector Data
svg.attr("data-compartment-id", this.compartment_id)
.attr("data-connector-start-y", boundingClientRect.y + (boundingClientRect.height / 2))
.attr("data-connector-start-x", boundingClientRect.x)
.attr("data-connector-end-y", boundingClientRect.y + (boundingClientRect.height / 2))
.attr("data-connector-end-x", boundingClientRect.x)
.attr("data-connector-id", this.id)
.attr("dragable", true)
.selectAll("*")
.attr("data-connector-start-y", boundingClientRect.y + (boundingClientRect.height / 2))
.attr("data-connector-start-x", boundingClientRect.x)
.attr("data-connector-end-y", boundingClientRect.y + (boundingClientRect.height / 2))
.attr("data-connector-end-x", boundingClientRect.x)
.attr("data-connector-id", this.id)
.attr("dragable", true);
}
console.groupEnd();
return svg;
}
// Return Artifact Specific Definition.
getSvgDefinition() {
let definition = this.newSVGDefinition(this, this.getArtifactReference());
let first_child = this.getParent().getChildOffset(this.getArtifactReference());
definition['svg']['x'] = first_child.dx;
definition['svg']['y'] = first_child.dy;
definition['svg']['width'] = this.dimensions['width'];
definition['svg']['height'] = this.dimensions['height'];
definition['rect']['stroke']['colour'] = stroke_colours.bark;
definition['rect']['stroke']['dash'] = 1;
return definition;
}
/*
** Property Sheet Load function
*/
loadProperties() {
let okitJson = this.getOkitJson();
let me = this;
$(jqId(PROPERTIES_PANEL)).load("propertysheets/autonomous_database.html", () => {
$('#is_free_tier').on('change', () => {
if($('#is_free_tier').is(':checked')) {
$('#license_model').val("LICENSE_INCLUDED");
$('#is_auto_scaling_enabled').prop('checked', false);
$('#license_model').attr('disabled', true);
$('#is_auto_scaling_enabled').attr('disabled', true);
} else {
$('#license_model').removeAttr('disabled');
$('#is_auto_scaling_enabled').removeAttr('disabled');
}
});
if (me.is_free_tier) {
me.artefact.license_model = "LICENSE_INCLUDED";
me.artefact.is_auto_scaling_enabled = false;
$('#license_model').attr('disabled', true);
$('#is_auto_scaling_enabled').attr('disabled', true);
}
// Load Reference Ids
// Network Security Groups
/*
let network_security_groups_select = $(jqId('nsg_ids'));
for (let network_security_group of okitJson.network_security_groups) {
network_security_groups_select.append($('<option>').attr('value', network_security_group.id).text(network_security_group.display_name));
}
*/
let network_security_groups_select = d3.select(d3Id('nsg_ids'));
for (let network_security_group of okitJson.network_security_groups) {
let div = network_security_groups_select.append('div');
div.append('input')
.attr('type', 'checkbox')
.attr('id', safeId(network_security_group.id))
.attr('value', network_security_group.id);
div.append('label')
.attr('for', safeId(network_security_group.id))
.text(network_security_group.display_name);
}
// Subnets
let subnet_select = $(jqId('subnet_id'));
subnet_select.append($('<option>').attr('value', '').text(''));
for (let subnet of okitJson.subnets) {
subnet_select.append($('<option>').attr('value', subnet.id).text(subnet.display_name));
}
loadPropertiesSheet(me.artefact);
});
}
/*
** Load and display Value Proposition
*/
loadValueProposition() {
$(jqId(VALUE_PROPOSITION_PANEL)).load("valueproposition/autonomous_database.html");
}
/*
** Static Functionality
*/
static getArtifactReference() {
return AutonomousDatabase.getArtifactReference();
}
static getDropTargets() {
return [Compartment.getArtifactReference(), Subnet.getArtifactReference()];
}
}