2023-01-17 20:25:18 +00:00
|
|
|
class DomainObjectViewProvider {
|
2023-05-18 21:54:46 +00:00
|
|
|
constructor(openmct) {
|
|
|
|
this.key = 'doViewProvider';
|
|
|
|
this.name = 'Domain Object View Provider';
|
|
|
|
this.openmct = openmct;
|
|
|
|
}
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
canView(domainObject) {
|
|
|
|
return domainObject.type === 'imageFileInput' || domainObject.type === 'jsonFileInput';
|
|
|
|
}
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
view(domainObject, objectPath) {
|
|
|
|
let content;
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
return {
|
|
|
|
show: function (element) {
|
|
|
|
const body = domainObject.selectFile.body;
|
|
|
|
const type = typeof body;
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
content = document.createElement('div');
|
|
|
|
content.id = 'file-input-type';
|
|
|
|
content.textContent = JSON.stringify(type);
|
|
|
|
element.appendChild(content);
|
|
|
|
},
|
|
|
|
destroy: function (element) {
|
|
|
|
element.removeChild(content);
|
|
|
|
content = undefined;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-01-17 20:25:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
2023-05-18 21:54:46 +00:00
|
|
|
const openmct = window.openmct;
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
openmct.types.addType('jsonFileInput', {
|
|
|
|
key: 'jsonFileInput',
|
|
|
|
name: 'JSON File Input Object',
|
|
|
|
creatable: true,
|
|
|
|
form: [
|
|
|
|
{
|
|
|
|
name: 'Upload File',
|
|
|
|
key: 'selectFile',
|
|
|
|
control: 'file-input',
|
|
|
|
required: true,
|
|
|
|
text: 'Select File...',
|
|
|
|
type: 'application/json',
|
|
|
|
property: ['selectFile']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
openmct.types.addType('imageFileInput', {
|
|
|
|
key: 'imageFileInput',
|
|
|
|
name: 'Image File Input Object',
|
|
|
|
creatable: true,
|
|
|
|
form: [
|
|
|
|
{
|
|
|
|
name: 'Upload File',
|
|
|
|
key: 'selectFile',
|
|
|
|
control: 'file-input',
|
|
|
|
required: true,
|
|
|
|
text: 'Select File...',
|
|
|
|
type: 'image/*',
|
|
|
|
property: ['selectFile']
|
|
|
|
}
|
|
|
|
]
|
|
|
|
});
|
2023-01-17 20:25:18 +00:00
|
|
|
|
2023-05-18 21:54:46 +00:00
|
|
|
openmct.objectViews.addProvider(new DomainObjectViewProvider(openmct));
|
2023-01-17 20:25:18 +00:00
|
|
|
});
|