Welcome to mirror list, hosted at ThFree Co, Russian Federation.

plugin.js « CouchDBSearchFolder « plugins « src - github.com/nasa/openmct.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7aee308293c837555dcef652c08e957d0c035aff (plain)
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
export default function (folderName, couchPlugin, searchFilter) {
    return function install(openmct) {
        const couchProvider = couchPlugin.couchProvider;

        openmct.objects.addRoot({
            namespace: 'couch-search',
            key: 'couch-search'
        });

        openmct.objects.addProvider('couch-search', {
            get(identifier) {
                if (identifier.key !== 'couch-search') {
                    return undefined;
                } else {
                    return Promise.resolve({
                        identifier,
                        type: 'folder',
                        name: folderName || "CouchDB Documents",
                        location: 'ROOT'
                    });
                }
            }
        });

        openmct.composition.addProvider({
            appliesTo(domainObject) {
                return domainObject.identifier.namespace === 'couch-search'
                    && domainObject.identifier.key === 'couch-search';
            },
            load() {
                return couchProvider.getObjectsByFilter(searchFilter).then(objects => {
                    return objects.map(object => object.identifier);
                });
            }
        });
    };

}