1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 // Fallback vocabulary that accepts any tag type. Will be used if
6 // no custom vocabulary provided.
12 window.Vocabulary = function(url) {
18 // Load vocabulary from rails' public directory
19 m.request(v.url.origin + '/vocabulary.json').then(function(resp) {
20 console.log('Vocabulary loaded')
22 }).catch(function(err) {
23 // Not found, use a default vocabulary
24 console.log('Using default vocabulary')
28 getDef: function(tagName) {
29 if (tagName in v.data.types) {
30 return v.data.types[tagName]
32 return {"type": "text"} // Default
35 getTypes: function() {
36 return Object.keys(v.data.types)
41 window.Tags = function(db, uuid, objType) {
47 objPath: '/arvados/v1/' + objType + '/' + uuid,
48 tagIdx: 0, // Will use this as the tag access key
54 // Get the tag list from the API server
57 t.objPath).then(function(obj){
59 Object.keys(obj.properties).map(function(k) {
60 t.addTag(k, obj.properties[k])
70 data: {properties: JSON.stringify(t.getAll())}
75 // return hash to be POSTed to API server
77 Object.keys(t.data).map(function(k) {
79 tags[a_tag.name] = a_tag.value
83 addTag: function(name, value) {
92 removeTag: function(tagIdx) {
93 if (tagIdx in t.data) {
97 getName: function(tagIdx) {
98 if (tagIdx in t.data) {
99 return t.data[tagIdx].name
102 get: function(tagIdx) {
103 if (tagIdx in t.data) {
104 return t.data[tagIdx]