@gravitee/ui-components 3.25.3-typescript-50960c3 → 3.25.3-typescript-9d19b68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -13
- package/src/atoms/gv-autocomplete.js +422 -1
- package/src/atoms/gv-button.js +397 -1
- package/src/atoms/gv-checkbox.js +178 -1
- package/src/atoms/gv-date-picker-calendar.js +812 -1
- package/src/atoms/gv-date-picker-cell.js +174 -1
- package/src/atoms/gv-date-picker.js +638 -1
- package/src/atoms/gv-file-upload.js +348 -1
- package/src/atoms/gv-icon.js +93 -1
- package/src/atoms/gv-image.js +135 -1
- package/src/atoms/gv-input-message.js +78 -1
- package/src/atoms/gv-input.js +508 -1
- package/src/atoms/gv-link.js +204 -1
- package/src/atoms/gv-message.js +133 -1
- package/src/atoms/gv-metric.js +112 -1
- package/src/atoms/gv-relative-time.js +143 -1
- package/src/atoms/gv-select-native.js +363 -1
- package/src/atoms/gv-select.js +413 -1
- package/src/atoms/gv-spinner.js +54 -1
- package/src/atoms/gv-state.js +125 -1
- package/src/atoms/gv-switch.js +235 -1
- package/src/atoms/gv-tag.js +162 -1
- package/src/atoms/gv-text.js +160 -1
- package/src/charts/gv-chart-bar.js +101 -1
- package/src/charts/gv-chart-gauge.js +92 -1
- package/src/charts/gv-chart-histogram.js +78 -1
- package/src/charts/gv-chart-line.js +218 -1
- package/src/charts/gv-chart-map.js +111 -1
- package/src/charts/gv-chart-pie.js +89 -1
- package/src/index.js +77 -1
- package/src/lib/cron-expression.js +176 -1
- package/src/lib/date.js +43 -1
- package/src/lib/events.js +26 -1
- package/src/lib/http-client-schema-form.js +67 -1
- package/src/lib/http.js +237 -1
- package/src/lib/i18n.js +93 -1
- package/src/lib/item.js +110 -1
- package/src/lib/properties.js +171 -1
- package/src/lib/schema-form.js +39 -1
- package/src/lib/studio.js +144 -1
- package/src/lib/style.js +39 -1
- package/src/lib/text-format.js +65 -1
- package/src/lib/theme.js +60 -1
- package/src/lib/utils.js +106 -1
- package/src/mixins/chart-element.js +153 -1
- package/src/mixins/input-element.js +136 -1
- package/src/mixins/item-resource.js +102 -1
- package/src/mixins/keyboard-element.js +62 -1
- package/src/mixins/update-after-browser.js +30 -1
- package/src/mixins/with-resize-observer.js +62 -1
- package/src/mixins/with-skeleton-attribute.js +109 -1
- package/src/molecules/gv-card-full.js +209 -1
- package/src/molecules/gv-card-list.js +101 -1
- package/src/molecules/gv-card.js +130 -1
- package/src/molecules/gv-category-list.js +56 -1
- package/src/molecules/gv-category.js +163 -1
- package/src/molecules/gv-code.js +334 -1
- package/src/molecules/gv-confirm.js +175 -1
- package/src/molecules/gv-cron-editor.js +685 -1
- package/src/molecules/gv-dropdown-menu.js +108 -1
- package/src/molecules/gv-expandable.js +116 -1
- package/src/molecules/gv-expression-language.js +263 -1
- package/src/molecules/gv-identity-picture.js +139 -1
- package/src/molecules/gv-list.js +214 -1
- package/src/molecules/gv-metrics.js +147 -1
- package/src/molecules/gv-modal.js +203 -1
- package/src/molecules/gv-nav.js +180 -1
- package/src/molecules/gv-option.js +230 -1
- package/src/molecules/gv-plans.js +400 -1
- package/src/molecules/gv-popover.js +323 -1
- package/src/molecules/gv-promote.js +203 -1
- package/src/molecules/gv-rating-list.js +341 -1
- package/src/molecules/gv-rating.js +234 -1
- package/src/molecules/gv-row-expandable.js +42 -1
- package/src/molecules/gv-row.js +205 -1
- package/src/molecules/gv-stats.js +110 -1
- package/src/molecules/gv-stepper.js +274 -1
- package/src/molecules/gv-table.js +644 -1
- package/src/molecules/gv-tree.js +238 -1
- package/src/organisms/gv-documentation.js +205 -1
- package/src/organisms/gv-header.js +276 -1
- package/src/organisms/gv-http-client.js +258 -1
- package/src/organisms/gv-menu.js +258 -1
- package/src/organisms/gv-newsletter-subscription.js +258 -1
- package/src/organisms/gv-pagination.js +179 -1
- package/src/organisms/gv-properties.js +860 -1
- package/src/organisms/gv-resizable-views.js +371 -1
- package/src/organisms/gv-resources.js +496 -1
- package/src/organisms/gv-schema-form-array.js +237 -1
- package/src/organisms/gv-schema-form-control-object.js +141 -1
- package/src/organisms/gv-schema-form-control.js +419 -1
- package/src/organisms/gv-schema-form.js +700 -1
- package/src/organisms/gv-tabs.js +201 -1
- package/src/organisms/gv-user-menu.js +298 -1
- package/src/organisms/gv-vertical-menu.js +119 -1
- package/src/policy-studio/gv-flow-step.js +443 -1
- package/src/policy-studio/gv-flow.js +595 -1
- package/src/policy-studio/gv-policy-studio-menu.js +689 -1
- package/src/policy-studio/gv-policy-studio.js +1712 -1
- package/src/styles/empty.js +35 -1
- package/src/styles/input.js +262 -1
- package/src/styles/link.js +31 -1
- package/src/styles/shapes.js +17 -1
- package/src/styles/skeleton.js +52 -1
- package/src/styles/zoom.js +39 -1
- package/src/theme/gv-theme.js +197 -1
- package/wc/gv-autocomplete.js +1 -1
- package/wc/gv-button.js +1 -1
- package/wc/gv-card-full.js +1 -1
- package/wc/gv-card-list.js +1 -1
- package/wc/gv-card.js +1 -1
- package/wc/gv-category-list.js +1 -1
- package/wc/gv-category.js +1 -1
- package/wc/gv-chart-bar.js +1 -1
- package/wc/gv-chart-gauge.js +1 -1
- package/wc/gv-chart-histogram.js +1 -1
- package/wc/gv-chart-line.js +1 -1
- package/wc/gv-chart-map.js +1 -1
- package/wc/gv-chart-pie.js +1 -1
- package/wc/gv-checkbox.js +1 -1
- package/wc/gv-code.js +1 -1
- package/wc/gv-confirm.js +1 -1
- package/wc/gv-cron-editor.js +1 -1
- package/wc/gv-date-picker-calendar.js +1 -1
- package/wc/gv-date-picker-cell.js +1 -1
- package/wc/gv-date-picker.js +1 -1
- package/wc/gv-documentation.js +1 -1
- package/wc/gv-dropdown-menu.js +1 -1
- package/wc/gv-expandable.js +1 -1
- package/wc/gv-expression-language.js +1 -1
- package/wc/gv-file-upload.js +1 -1
- package/wc/gv-flow-step.js +1 -1
- package/wc/gv-flow.js +1 -1
- package/wc/gv-header.js +1 -1
- package/wc/gv-http-client.js +1 -1
- package/wc/gv-icon.js +1 -1
- package/wc/gv-identity-picture.js +1 -1
- package/wc/gv-image.js +1 -1
- package/wc/gv-input-message.js +1 -1
- package/wc/gv-input.js +1 -1
- package/wc/gv-link.js +1 -1
- package/wc/gv-list.js +1 -1
- package/wc/gv-menu.js +1 -1
- package/wc/gv-message.js +1 -1
- package/wc/gv-metric.js +1 -1
- package/wc/gv-metrics.js +1 -1
- package/wc/gv-modal.js +1 -1
- package/wc/gv-nav.js +1 -1
- package/wc/gv-newsletter-subscription.js +1 -1
- package/wc/gv-option.js +1 -1
- package/wc/gv-pagination.js +1 -1
- package/wc/gv-plans.js +1 -1
- package/wc/gv-policy-studio-menu.js +1 -1
- package/wc/gv-policy-studio.js +1 -1
- package/wc/gv-popover.js +1 -1
- package/wc/gv-promote.js +1 -1
- package/wc/gv-properties.js +1 -1
- package/wc/gv-rating-list.js +1 -1
- package/wc/gv-rating.js +1 -1
- package/wc/gv-relative-time.js +1 -1
- package/wc/gv-resizable-views.js +1 -1
- package/wc/gv-resources.js +1 -1
- package/wc/gv-row-expandable.js +1 -1
- package/wc/gv-row.js +1 -1
- package/wc/gv-schema-form-array.js +1 -1
- package/wc/gv-schema-form-control-object.js +1 -1
- package/wc/gv-schema-form-control.js +1 -1
- package/wc/gv-schema-form.js +1 -1
- package/wc/gv-select-native.js +1 -1
- package/wc/gv-select.js +1 -1
- package/wc/gv-spinner.js +1 -1
- package/wc/gv-state.js +1 -1
- package/wc/gv-stats.js +1 -1
- package/wc/gv-stepper.js +1 -1
- package/wc/gv-switch.js +1 -1
- package/wc/gv-table.js +1 -1
- package/wc/gv-tabs.js +1 -1
- package/wc/gv-tag.js +1 -1
- package/wc/gv-text.js +1 -1
- package/wc/gv-theme.js +1 -1
- package/wc/gv-tree.js +1 -1
- package/wc/gv-user-menu.js +1 -1
- package/wc/gv-vertical-menu.js +1 -1
|
@@ -1 +1,496 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { css, html, LitElement } from 'lit';
|
|
17
|
+
import './gv-schema-form';
|
|
18
|
+
import './gv-resizable-views';
|
|
19
|
+
import './gv-documentation';
|
|
20
|
+
import '../molecules/gv-table';
|
|
21
|
+
import '../atoms/gv-button';
|
|
22
|
+
import '../molecules/gv-option';
|
|
23
|
+
import '../atoms/gv-switch';
|
|
24
|
+
import '../atoms/gv-icon';
|
|
25
|
+
import { dispatchCustomEvent } from '../lib/events';
|
|
26
|
+
import { uuid } from '../lib/utils';
|
|
27
|
+
import { KeyboardElement, KEYS } from '../mixins/keyboard-element';
|
|
28
|
+
import { empty } from '../styles/empty';
|
|
29
|
+
export class GvResources extends KeyboardElement(LitElement) {
|
|
30
|
+
static get properties() {
|
|
31
|
+
return {
|
|
32
|
+
resources: { type: Array },
|
|
33
|
+
_resources: { type: Array, attribute: false },
|
|
34
|
+
types: { type: Array },
|
|
35
|
+
documentation: { type: Object },
|
|
36
|
+
_currentResource: { type: Object, attribute: false },
|
|
37
|
+
_currentResourceLoading: { type: Boolean, attribute: false },
|
|
38
|
+
_filter: { type: String },
|
|
39
|
+
readonly: { type: Boolean, reflect: true },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
constructor() {
|
|
43
|
+
super();
|
|
44
|
+
this.resources = [];
|
|
45
|
+
this.types = [];
|
|
46
|
+
this._currentResource = null;
|
|
47
|
+
this._emptymessage = 'No resource';
|
|
48
|
+
}
|
|
49
|
+
onKeyboard() {
|
|
50
|
+
if (this.isPressed(KEYS.Esc)) {
|
|
51
|
+
this._onCancelResourceForm();
|
|
52
|
+
}
|
|
53
|
+
if (this.isPressed(KEYS.Shift, KEYS.Ctrl, KEYS.Space)) {
|
|
54
|
+
const search = this.shadowRoot.querySelector('#search-resource');
|
|
55
|
+
if (search) {
|
|
56
|
+
search.focus();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
firstUpdated() {
|
|
61
|
+
const views = this.shadowRoot.querySelector('gv-resizable-views');
|
|
62
|
+
if (views != null) {
|
|
63
|
+
views.updateComplete.then(() => {
|
|
64
|
+
this._maximizeTopView();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
set resources(resources) {
|
|
69
|
+
this._resources = this._generateId(resources);
|
|
70
|
+
}
|
|
71
|
+
get resources() {
|
|
72
|
+
return this._resources;
|
|
73
|
+
}
|
|
74
|
+
_generateId(list) {
|
|
75
|
+
if (list) {
|
|
76
|
+
return list.map((e) => {
|
|
77
|
+
if (e._id == null) {
|
|
78
|
+
e._id = uuid();
|
|
79
|
+
}
|
|
80
|
+
return e;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return list;
|
|
84
|
+
}
|
|
85
|
+
_getResizableViews() {
|
|
86
|
+
return this.shadowRoot.querySelector('gv-resizable-views');
|
|
87
|
+
}
|
|
88
|
+
_maximizeTopView() {
|
|
89
|
+
this._getResizableViews().resize(60, 40);
|
|
90
|
+
}
|
|
91
|
+
_maximizeBottomView() {
|
|
92
|
+
this._getResizableViews().maximizeBottom();
|
|
93
|
+
}
|
|
94
|
+
_splitMainViews() {
|
|
95
|
+
this._getResizableViews().split();
|
|
96
|
+
}
|
|
97
|
+
_onCancelResourceForm() {
|
|
98
|
+
this._currentResource = null;
|
|
99
|
+
this.documentation = null;
|
|
100
|
+
this._maximizeTopView();
|
|
101
|
+
}
|
|
102
|
+
_removeResource(item) {
|
|
103
|
+
this.resources = this.resources.filter((resource) => resource._id !== item._id);
|
|
104
|
+
this._onCancelResourceForm();
|
|
105
|
+
dispatchCustomEvent(this, 'change', { resources: this.resources });
|
|
106
|
+
}
|
|
107
|
+
_buildResourceSchema(resourceType) {
|
|
108
|
+
const defaultSchema = {
|
|
109
|
+
properties: {
|
|
110
|
+
name: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
title: 'Resource name',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ['name'],
|
|
116
|
+
};
|
|
117
|
+
const schema = typeof resourceType.schema === 'string' ? JSON.parse(resourceType.schema) : resourceType.schema;
|
|
118
|
+
return {
|
|
119
|
+
properties: { ...defaultSchema.properties, ...schema.properties },
|
|
120
|
+
required: [...defaultSchema.required, ...schema.required],
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
_onCreateResource({ detail }) {
|
|
124
|
+
this._currentResourceLoading = true;
|
|
125
|
+
const defaultResourceType = this.types.find((type) => type.id === detail.id);
|
|
126
|
+
const schema = this._buildResourceSchema(defaultResourceType);
|
|
127
|
+
this._currentResource = {
|
|
128
|
+
type: defaultResourceType.id,
|
|
129
|
+
title: 'Create resource',
|
|
130
|
+
icon: 'code:plus',
|
|
131
|
+
schema,
|
|
132
|
+
values: {},
|
|
133
|
+
submitLabel: 'Add',
|
|
134
|
+
dirty: true,
|
|
135
|
+
};
|
|
136
|
+
this._maximizeBottomView();
|
|
137
|
+
this._onFetchDocumentation();
|
|
138
|
+
setTimeout(() => (this._currentResourceLoading = false), 600);
|
|
139
|
+
}
|
|
140
|
+
_onSubmitResourceForm({ detail }) {
|
|
141
|
+
delete this._currentResource._values;
|
|
142
|
+
const { type } = this._currentResource;
|
|
143
|
+
const { _id, name, ...configuration } = detail.values;
|
|
144
|
+
const resource = {
|
|
145
|
+
_id,
|
|
146
|
+
type,
|
|
147
|
+
name,
|
|
148
|
+
configuration,
|
|
149
|
+
};
|
|
150
|
+
if (detail.values._id != null) {
|
|
151
|
+
const index = this.resources.findIndex((r) => r._id === resource._id);
|
|
152
|
+
this.resources[index] = { ...this.resources[index], ...resource };
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (this.resources == null) {
|
|
156
|
+
this.resources = [];
|
|
157
|
+
}
|
|
158
|
+
resource._id = uuid();
|
|
159
|
+
resource.enabled = true;
|
|
160
|
+
this.resources.push(resource);
|
|
161
|
+
}
|
|
162
|
+
this._onCancelResourceForm();
|
|
163
|
+
dispatchCustomEvent(this, 'change', { resources: this.resources });
|
|
164
|
+
}
|
|
165
|
+
_onChangeResourceForm({ detail }) {
|
|
166
|
+
this._currentResource._values = detail.values;
|
|
167
|
+
}
|
|
168
|
+
_onResetResourceForm() {
|
|
169
|
+
delete this._currentResource._values;
|
|
170
|
+
}
|
|
171
|
+
_findResourceById(id) {
|
|
172
|
+
return this.types.find((resource) => resource.id === id);
|
|
173
|
+
}
|
|
174
|
+
// For readonly mode
|
|
175
|
+
_onSelectResource({ detail: { items } }) {
|
|
176
|
+
if (items.length > 0) {
|
|
177
|
+
this._onEditResource(items[0]);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
this._onCancelResourceForm();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
_onEditResource(resource) {
|
|
184
|
+
const values = { ...resource, ...resource.configuration };
|
|
185
|
+
delete values.configuration;
|
|
186
|
+
const resourceType = this._findResourceById(resource.type);
|
|
187
|
+
this._currentResource = {
|
|
188
|
+
_id: resource._id,
|
|
189
|
+
title: 'Resource configuration',
|
|
190
|
+
type: resource.type,
|
|
191
|
+
icon: 'design:edit',
|
|
192
|
+
schema: this._buildResourceSchema(resourceType),
|
|
193
|
+
values,
|
|
194
|
+
submitLabel: 'Update',
|
|
195
|
+
};
|
|
196
|
+
this._splitMainViews();
|
|
197
|
+
this._onFetchDocumentation();
|
|
198
|
+
}
|
|
199
|
+
_onCloseDocumentation() {
|
|
200
|
+
this.documentation = null;
|
|
201
|
+
}
|
|
202
|
+
_getCurrentResourceType() {
|
|
203
|
+
return this._currentResource ? this._findResourceById(this._currentResource.type) : null;
|
|
204
|
+
}
|
|
205
|
+
_onFetchDocumentation() {
|
|
206
|
+
dispatchCustomEvent(this, 'fetch-documentation', { target: this, resourceType: this._getCurrentResourceType() });
|
|
207
|
+
}
|
|
208
|
+
get dirty() {
|
|
209
|
+
const form = this.shadowRoot.querySelector('gv-schema-form');
|
|
210
|
+
return form && form.dirty;
|
|
211
|
+
}
|
|
212
|
+
confirm() {
|
|
213
|
+
const form = this.shadowRoot.querySelector('gv-schema-form');
|
|
214
|
+
if (form) {
|
|
215
|
+
return form.confirm().then(() => this._onCancelResourceForm());
|
|
216
|
+
}
|
|
217
|
+
return Promise.resolve();
|
|
218
|
+
}
|
|
219
|
+
_onChangeResourceState(item, event) {
|
|
220
|
+
const index = this.resources.find((r) => r._id === item._id);
|
|
221
|
+
this.resources[index] = { ...this.resources[index], enabled: item.enabled };
|
|
222
|
+
dispatchCustomEvent(this, 'change', { resources: this.resources });
|
|
223
|
+
}
|
|
224
|
+
_renderForm() {
|
|
225
|
+
const values = { ...this._currentResource.values, ...this._currentResource._values };
|
|
226
|
+
return html `<gv-schema-form
|
|
227
|
+
scrollable
|
|
228
|
+
.schema="${this._currentResource.schema}"
|
|
229
|
+
.values="${values}"
|
|
230
|
+
submitLabel="${this._currentResource.submitLabel}"
|
|
231
|
+
has-header
|
|
232
|
+
.icon="${this._currentResource.icon}"
|
|
233
|
+
validate-on-render
|
|
234
|
+
.dirty="${this._currentResource.dirty || this._currentResource._values != null}"
|
|
235
|
+
?readonly="${this.readonly}"
|
|
236
|
+
@gv-schema-form:change="${this._onChangeResourceForm}"
|
|
237
|
+
@gv-schema-form:reset="${this._onResetResourceForm}"
|
|
238
|
+
@gv-schema-form:submit="${this._onSubmitResourceForm}"
|
|
239
|
+
>
|
|
240
|
+
<div slot="title" class="form-title">${this._currentResource.title}</div>
|
|
241
|
+
<gv-button
|
|
242
|
+
slot="header-left"
|
|
243
|
+
icon="general:close"
|
|
244
|
+
outlined
|
|
245
|
+
small
|
|
246
|
+
@gv-button:click="${this._onCancelResourceForm}"
|
|
247
|
+
title="Close (esc)"
|
|
248
|
+
></gv-button>
|
|
249
|
+
<gv-button
|
|
250
|
+
slot="header-left"
|
|
251
|
+
icon="home:book"
|
|
252
|
+
?disabled="${this.documentation != null}"
|
|
253
|
+
outlined
|
|
254
|
+
small
|
|
255
|
+
@gv-button:click="${this._onFetchDocumentation}"
|
|
256
|
+
title="Open documentation"
|
|
257
|
+
></gv-button>
|
|
258
|
+
</gv-schema-form>`;
|
|
259
|
+
}
|
|
260
|
+
_renderDoc() {
|
|
261
|
+
return html `<gv-documentation
|
|
262
|
+
.text="${this.documentation.content}"
|
|
263
|
+
.image="${this.documentation.image}"
|
|
264
|
+
@gv-documentation:close="${this._onCloseDocumentation}"
|
|
265
|
+
></gv-documentation>`;
|
|
266
|
+
}
|
|
267
|
+
_renderBottom() {
|
|
268
|
+
if (this.documentation && this._currentResource) {
|
|
269
|
+
return html ` <gv-resizable-views direction="horizontal" no-overflow>
|
|
270
|
+
<div slot="top">${this._renderForm()}</div>
|
|
271
|
+
<div slot="bottom">${this._renderDoc()}</div>
|
|
272
|
+
</gv-resizable-views>`;
|
|
273
|
+
}
|
|
274
|
+
else if (this._currentResource) {
|
|
275
|
+
return this._renderForm();
|
|
276
|
+
}
|
|
277
|
+
else if (this.documentation) {
|
|
278
|
+
return this._renderDoc();
|
|
279
|
+
}
|
|
280
|
+
else if (this.readonly !== true) {
|
|
281
|
+
const resourceOpts = this.types.map((resource) => {
|
|
282
|
+
return { id: resource.id, title: resource.name, description: resource.description, image: resource.icon };
|
|
283
|
+
});
|
|
284
|
+
return html `<div class="resources-bottom-container">
|
|
285
|
+
<gv-option class="resource__option" .options="${resourceOpts}" @gv-option:select="${this._onCreateResource}">
|
|
286
|
+
</div>`;
|
|
287
|
+
}
|
|
288
|
+
else if (this.readonly && this.resources.length > 0) {
|
|
289
|
+
return html `<div class="resources-bottom-container empty">You can see the resource configuration by clicking on it</div>`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
_onSearchResource({ detail }) {
|
|
293
|
+
this._filter = detail;
|
|
294
|
+
}
|
|
295
|
+
_onClearResource() {
|
|
296
|
+
this._filter = null;
|
|
297
|
+
}
|
|
298
|
+
render() {
|
|
299
|
+
const options = {
|
|
300
|
+
selectable: true,
|
|
301
|
+
data: [
|
|
302
|
+
{ field: 'name', label: 'Name' },
|
|
303
|
+
{
|
|
304
|
+
field: 'type',
|
|
305
|
+
width: '50px',
|
|
306
|
+
type: 'gv-image',
|
|
307
|
+
attributes: {
|
|
308
|
+
src: (item) => {
|
|
309
|
+
const resourceType = this._findResourceById(item.type);
|
|
310
|
+
return resourceType ? resourceType.icon : null;
|
|
311
|
+
},
|
|
312
|
+
style: 'width:40px;height:40px;',
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
{ field: 'type', label: 'Type' },
|
|
316
|
+
{
|
|
317
|
+
field: 'enabled',
|
|
318
|
+
type: 'gv-switch',
|
|
319
|
+
title: (item) => (item.enabled ? 'Click to disable' : 'Click to enable'),
|
|
320
|
+
width: '50px',
|
|
321
|
+
attributes: {
|
|
322
|
+
readonly: this.readonly,
|
|
323
|
+
'ongv-switch:input': (item, event) => this._onChangeResourceState(item, event),
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
};
|
|
328
|
+
if (this.readonly !== true) {
|
|
329
|
+
options.data.push({
|
|
330
|
+
type: 'gv-button',
|
|
331
|
+
width: '50px',
|
|
332
|
+
attributes: {
|
|
333
|
+
onClick: (item) => this._removeResource(item),
|
|
334
|
+
title: 'remove',
|
|
335
|
+
danger: true,
|
|
336
|
+
outlined: true,
|
|
337
|
+
icon: 'home:trash',
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
const filteredResources = this._filter != null
|
|
342
|
+
? this.resources.filter((resource) => {
|
|
343
|
+
return (resource.name.toLowerCase() + resource.type.toLowerCase()).includes(this._filter);
|
|
344
|
+
})
|
|
345
|
+
: this.resources;
|
|
346
|
+
return html `<div class="resources">
|
|
347
|
+
<gv-resizable-views no-overflow>
|
|
348
|
+
<div slot="top" class="box">
|
|
349
|
+
<div class="container">
|
|
350
|
+
<div class="header">
|
|
351
|
+
<div class="title">Manage global resources <span>(${this.resources.length})</span></div>
|
|
352
|
+
<gv-input
|
|
353
|
+
id="search-resource"
|
|
354
|
+
class="search-input"
|
|
355
|
+
placeholder="Filter resources (Shift + Ctrl + Space)"
|
|
356
|
+
type="search"
|
|
357
|
+
small
|
|
358
|
+
@gv-input:input="${this._onSearchResource}"
|
|
359
|
+
@gv-input:clear="${this._onClearResource}"
|
|
360
|
+
></gv-input>
|
|
361
|
+
</div>
|
|
362
|
+
<div class="content">
|
|
363
|
+
<div class="table-container">
|
|
364
|
+
<gv-table
|
|
365
|
+
.options="${options}"
|
|
366
|
+
.items="${filteredResources}"
|
|
367
|
+
emptymessage="${this._emptymessage}"
|
|
368
|
+
@gv-table:select="${this._onSelectResource}"
|
|
369
|
+
order="name"
|
|
370
|
+
rowheight="50px"
|
|
371
|
+
></gv-table>
|
|
372
|
+
</div>
|
|
373
|
+
</div>
|
|
374
|
+
</div>
|
|
375
|
+
</div>
|
|
376
|
+
<div slot="bottom">${this._renderBottom()}</div>
|
|
377
|
+
</gv-resizable-views>
|
|
378
|
+
</div>`;
|
|
379
|
+
}
|
|
380
|
+
static get styles() {
|
|
381
|
+
return [
|
|
382
|
+
empty,
|
|
383
|
+
// language=CSS
|
|
384
|
+
css `
|
|
385
|
+
:host {
|
|
386
|
+
box-sizing: border-box;
|
|
387
|
+
height: 100%;
|
|
388
|
+
width: 100%;
|
|
389
|
+
display: block;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.resources {
|
|
393
|
+
display: flex;
|
|
394
|
+
height: 100%;
|
|
395
|
+
width: 100%;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
gv-resizable-views {
|
|
399
|
+
height: 100%;
|
|
400
|
+
width: 100%;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
gv-table {
|
|
404
|
+
--gv-table-rows--ov: none;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.header {
|
|
408
|
+
border-bottom: 1px solid #d9d9d9;
|
|
409
|
+
display: flex;
|
|
410
|
+
min-height: 45px;
|
|
411
|
+
align-items: center;
|
|
412
|
+
margin-bottom: 0.5rem;
|
|
413
|
+
padding: 0 0.5rem;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.header .title {
|
|
417
|
+
color: #28444f;
|
|
418
|
+
font-size: 18px;
|
|
419
|
+
display: flex;
|
|
420
|
+
align-items: flex-end;
|
|
421
|
+
flex: 1;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.header .title span {
|
|
425
|
+
font-size: 12px;
|
|
426
|
+
margin-left: 8px;
|
|
427
|
+
opacity: 0.7;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.box {
|
|
431
|
+
position: absolute;
|
|
432
|
+
display: flex;
|
|
433
|
+
flex-direction: column;
|
|
434
|
+
width: 100%;
|
|
435
|
+
top: 0;
|
|
436
|
+
bottom: 0;
|
|
437
|
+
left: 0;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.container {
|
|
441
|
+
flex-grow: 1;
|
|
442
|
+
|
|
443
|
+
display: flex;
|
|
444
|
+
flex-direction: column;
|
|
445
|
+
|
|
446
|
+
/* for Firefox */
|
|
447
|
+
min-height: 0;
|
|
448
|
+
height: 100%;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.content {
|
|
452
|
+
background: white;
|
|
453
|
+
flex-grow: 1;
|
|
454
|
+
|
|
455
|
+
overflow: auto;
|
|
456
|
+
|
|
457
|
+
/* for Firefox */
|
|
458
|
+
min-height: 0;
|
|
459
|
+
padding: 0.5rem;
|
|
460
|
+
|
|
461
|
+
display: flex;
|
|
462
|
+
flex-direction: column;
|
|
463
|
+
align-items: center;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.form-title {
|
|
467
|
+
text-transform: uppercase;
|
|
468
|
+
letter-spacing: 0.2rem;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
.resources-bottom-container {
|
|
472
|
+
display: flex;
|
|
473
|
+
justify-content: center;
|
|
474
|
+
align-items: center;
|
|
475
|
+
height: 100%;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.table-container {
|
|
479
|
+
max-width: 1200px;
|
|
480
|
+
display: flex;
|
|
481
|
+
flex-direction: column;
|
|
482
|
+
width: 100%;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.search-input {
|
|
486
|
+
width: 300px;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.resource__option {
|
|
490
|
+
--gv-option-button--maw: 175px;
|
|
491
|
+
}
|
|
492
|
+
`,
|
|
493
|
+
];
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
window.customElements.define('gv-resources', GvResources);
|