@dataloop-ai/components 0.18.123 → 0.18.125

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.18.123",
3
+ "version": "0.18.125",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -731,11 +731,10 @@ export default defineComponent({
731
731
  display: flex;
732
732
  align-items: center;
733
733
 
734
+ &--small,
734
735
  &--s {
735
- margin: 4px auto auto;
736
- }
737
- &--small {
738
- margin: 4px auto auto;
736
+ margin-bottom: 0;
737
+ margin-right: 4px;
739
738
  }
740
739
  }
741
740
 
@@ -64,7 +64,8 @@
64
64
  </div>
65
65
  <dl-smart-search-json-editor-dialog
66
66
  v-model="showJSONEditor"
67
- :json="stringifiedJSON"
67
+ :json="modelValue"
68
+ :options="selectOptions"
68
69
  @search="handleJSONSearch"
69
70
  @change="handleJSONChange"
70
71
  />
@@ -75,7 +76,7 @@ import { defineComponent, PropType, ref, computed, toRefs } from 'vue-demi'
75
76
  import { DlButton } from '../../../basic'
76
77
  import { DlSmartSearchInput, DlSmartSearchJsonEditorDialog } from './components'
77
78
  import { Schema, Alias } from '../../../../hooks/use-suggestions'
78
- import { Filters, ColorSchema, SearchStatus } from './types'
79
+ import { ColorSchema, SearchStatus, DlSmartSearchFilter } from './types'
79
80
  import { v4 } from 'uuid'
80
81
  import { stateManager } from '../../../../StateManager'
81
82
 
@@ -115,8 +116,8 @@ export default defineComponent({
115
116
  })
116
117
  },
117
118
  filters: {
118
- type: Object as PropType<Filters>,
119
- default: () => ({} as Filters)
119
+ type: Array as PropType<DlSmartSearchFilter[]>,
120
+ default: () => [] as DlSmartSearchFilter[]
120
121
  },
121
122
  disabled: {
122
123
  type: Boolean,
@@ -179,8 +180,6 @@ export default defineComponent({
179
180
  //#endregion
180
181
 
181
182
  //#region computed
182
- const stringifiedJSON = computed(() => JSON.stringify(modelValue.value))
183
-
184
183
  const cssVars = computed(() => ({
185
184
  '--dl-smart-search-max-width': isFocused.value
186
185
  ? '100%'
@@ -196,24 +195,9 @@ export default defineComponent({
196
195
  }
197
196
  })
198
197
 
199
- const selectedOptions = computed(() => {
200
- const options: Record<string, string>[] = [
201
- {
202
- label: 'New Query',
203
- value: '{}'
204
- }
205
- ]
206
-
207
- const queryFilters = filters.value?.saved ?? []
208
- for (const filter of queryFilters) {
209
- options.push({
210
- label: filter.name,
211
- value: filter.query
212
- })
213
- }
214
-
215
- return options
216
- })
198
+ const selectOptions = computed<DlSmartSearchFilter[]>(
199
+ () => filters.value ?? []
200
+ )
217
201
  //#endregion
218
202
 
219
203
  //#region methods
@@ -271,10 +255,9 @@ export default defineComponent({
271
255
  preventUpdate,
272
256
  selectedOption,
273
257
  cssVars,
274
- selectedOptions,
258
+ selectOptions,
275
259
  emitSearchQuery,
276
260
  showJSONEditor,
277
- stringifiedJSON,
278
261
  handleJSONSearch,
279
262
  handleJSONChange
280
263
  }
@@ -1,5 +1,4 @@
1
1
  <template>
2
- <!-- todo: Add support for saved queries-->
3
2
  <div>
4
3
  <dl-dialog-box
5
4
  v-model="isOpen"
@@ -21,10 +20,9 @@
21
20
  style="margin-bottom: 10px"
22
21
  >
23
22
  <dl-select
24
- disabled
25
23
  :model-value="selectedOption"
26
24
  width="200px"
27
- :options="options"
25
+ :options="selectOptions"
28
26
  placeholder="New Query"
29
27
  @update:model-value="onQuerySelect"
30
28
  />
@@ -48,7 +46,7 @@
48
46
  <template #footer>
49
47
  <div class="json-editor-footer">
50
48
  <dl-button
51
- :disabled="true || canDelete"
49
+ :disabled="!hasActiveFilter"
52
50
  icon="icon-dl-delete"
53
51
  label="Delete Query"
54
52
  flat
@@ -58,15 +56,18 @@
58
56
  />
59
57
  <div class="json-editor-footer-actions">
60
58
  <dl-button
61
- disabled
62
59
  style="margin-right: 14px"
63
60
  outlined
64
61
  label="Save As"
65
62
  @click="showSaveDialog = true"
66
63
  />
67
64
  <dl-button
68
- label="Search"
69
- @click="search"
65
+ :label="
66
+ hasActiveFilter ? 'Save & Search' : 'Search'
67
+ "
68
+ @click="
69
+ () => (hasActiveFilter ? saveQuery() : search())
70
+ "
70
71
  />
71
72
  </div>
72
73
  </div>
@@ -97,6 +98,7 @@
97
98
  <dl-button
98
99
  :disabled="!newQueryName"
99
100
  outlined
101
+ style="margin-right: 5px"
100
102
  @click="saveQuery"
101
103
  >
102
104
  Save
@@ -124,7 +126,8 @@
124
126
  size="h3"
125
127
  style="display: flex; justify-content: center"
126
128
  >
127
- Are you sure you want to delete {{ selectedOption.label }}?
129
+ Are you sure you want to delete
130
+ {{ selectedOption.label }}?
128
131
  </dl-typography>
129
132
  </template>
130
133
  <template #footer>
@@ -146,8 +149,6 @@ import {
146
149
  toRefs,
147
150
  computed,
148
151
  nextTick,
149
- onMounted,
150
- getCurrentInstance,
151
152
  watch
152
153
  } from 'vue-demi'
153
154
  import { DlSelect } from '../../../DlSelect'
@@ -158,8 +159,8 @@ import { DlJsonEditor } from '../../../DlJsonEditor'
158
159
  import { DlTypography } from '../../../../essential'
159
160
  import { DlInput } from '../../../DlInput'
160
161
  import { stateManager } from '../../../../../StateManager'
161
- import { isEqual } from 'lodash'
162
- import { registerToWindow } from '../../../../../utils'
162
+ import { cloneDeep, isEqual, uniqBy } from 'lodash'
163
+ import { DlSmartSearchFilter } from '../types'
163
164
 
164
165
  export default defineComponent({
165
166
  components: {
@@ -183,44 +184,105 @@ export default defineComponent({
183
184
  },
184
185
  json: {
185
186
  required: true,
186
- type: String
187
+ type: Object as PropType<Record<string, any>>
187
188
  },
188
189
  options: {
189
190
  required: false,
190
191
  type: Array as PropType<DlSelectOption[]>,
191
192
  default: () => [] as DlSelectOption[]
193
+ },
194
+ selectedFilter: {
195
+ required: false,
196
+ type: String,
197
+ default: null
192
198
  }
193
199
  },
194
- emits: ['update:modelValue', 'search', 'change', 'update:options'],
200
+ emits: [
201
+ 'update:modelValue',
202
+ 'search',
203
+ 'change',
204
+ 'update:options',
205
+ 'save',
206
+ 'delete',
207
+ 'select'
208
+ ],
195
209
  setup(props, { emit }) {
196
- const { modelValue, options, json } = toRefs(props)
210
+ const { modelValue, options, json, selectedFilter } = toRefs(props)
197
211
 
198
212
  const isOpen = computed({
199
213
  get: () => modelValue.value,
200
214
  set: (val) => emit('update:modelValue', val)
201
215
  })
202
216
 
217
+ const currentQuery = ref<{ [key: string]: any }>(cloneDeep(json.value))
203
218
  const jsonEditor = ref<any>(null)
204
219
  const showSaveDialog = ref(false)
205
220
  const showDeleteDialog = ref(false)
206
- const stringifiedJSON = ref(json.value)
207
221
  const newQueryName = ref('')
222
+
223
+ const selectOptions = computed<DlSelectOption[]>(() => {
224
+ return uniqBy(
225
+ [
226
+ {
227
+ label: 'New Query',
228
+ value: cloneDeep(json.value ?? {})
229
+ }
230
+ ].concat(options.value),
231
+ 'label'
232
+ )
233
+ })
208
234
  const selectedOption = ref<DlSelectOption>(
209
- options.value.find((o) => isEqual(o.value, json.value)) ?? {
235
+ options.value.find((o) => isEqual(o.value, currentQuery.value)) ?? {
210
236
  label: 'New Query',
211
- value: json.value
237
+ value: currentQuery.value
212
238
  }
213
239
  )
214
240
 
241
+ watch(
242
+ selectedFilter,
243
+ () => {
244
+ selectedOption.value = options.value.find(
245
+ (o) => o.label === selectedFilter.value
246
+ ) ?? {
247
+ label: 'New Query',
248
+ value: currentQuery.value
249
+ }
250
+
251
+ if (selectedOption.value.label !== 'New Query') {
252
+ currentQuery.value = cloneDeep(selectedOption.value.value)
253
+ }
254
+ },
255
+ { immediate: true }
256
+ )
257
+
215
258
  const alignJSON = () => {
216
- jsonEditor.value.format()
259
+ jsonEditor.value?.format()
217
260
  }
218
261
 
219
262
  const onQuerySelect = (option: DlSelectOption) => {
220
- selectedOption.value = option
221
- stringifiedJSON.value = option.value
263
+ if (option.label === selectedOption.value.label) {
264
+ return
265
+ }
266
+
267
+ selectedOption.value = cloneDeep(option)
268
+ currentQuery.value = cloneDeep(option.value)
269
+ nextTick(() => {
270
+ alignJSON()
271
+ // wtf oa ?
272
+ nextTick(() => {
273
+ alignJSON()
274
+ })
275
+ })
276
+ emit('select', option)
222
277
  }
223
278
 
279
+ const stringifiedJSON = computed<string>({
280
+ get: () => JSON.stringify(currentQuery.value),
281
+ set: (val) => {
282
+ currentQuery.value = toObject(val)
283
+ }
284
+ })
285
+
224
286
  const toObject = (json: string) => {
225
287
  try {
226
288
  return JSON.parse(json)
@@ -231,9 +293,8 @@ export default defineComponent({
231
293
  }
232
294
 
233
295
  const search = () => {
234
- const parsed = toObject(stringifiedJSON.value)
235
- if (!parsed) return
236
- emit('search', parsed)
296
+ if (!currentQuery.value) return
297
+ emit('search', currentQuery.value)
237
298
  isOpen.value = false
238
299
  }
239
300
 
@@ -244,16 +305,23 @@ export default defineComponent({
244
305
  }
245
306
 
246
307
  const saveQuery = (searchAfterSave = false) => {
247
- const newOptions = options.value.concat([
248
- {
249
- label: newQueryName.value,
250
- value: stringifiedJSON.value
251
- }
252
- ])
308
+ let toSave: DlSmartSearchFilter = hasActiveFilter.value
309
+ ? selectedOption.value
310
+ : ({} as DlSmartSearchFilter)
311
+ toSave = Object.assign({}, toSave, {
312
+ label: hasActiveFilter.value
313
+ ? selectedOption.value.label
314
+ : newQueryName.value,
315
+ value: currentQuery.value
316
+ })
317
+
318
+ const newOptions = options.value.concat([toSave])
253
319
 
320
+ emit('save', toSave)
254
321
  emit('update:options', newOptions)
255
322
 
256
323
  showSaveDialog.value = false
324
+ newQueryName.value = ''
257
325
  nextTick(() => {
258
326
  if (searchAfterSave) {
259
327
  search()
@@ -261,25 +329,38 @@ export default defineComponent({
261
329
  })
262
330
  }
263
331
 
264
- const canDelete = computed(
332
+ const hasActiveFilter = computed(
265
333
  () => selectedOption.value.label !== 'New Query'
266
334
  )
267
335
 
268
336
  const deleteQuery = () => {
337
+ const toDelete = options.value.find(
338
+ (o: DlSelectOption) => o.label === selectedOption.value.label
339
+ )
269
340
  const newOptions = options.value.filter(
270
- (o: DlSelectOption) => o.value !== selectedOption.value.label
341
+ (o: DlSelectOption) => o.label !== selectedOption.value.label
271
342
  )
272
343
 
344
+ emit('delete', toDelete)
273
345
  emit('update:options', newOptions)
274
346
  selectedOption.value = {
275
347
  label: 'New Query',
276
- value: '{}'
348
+ value: {}
277
349
  }
350
+ currentQuery.value = {}
278
351
  showDeleteDialog.value = false
279
352
  }
280
353
 
281
354
  watch(json, () => {
282
- stringifiedJSON.value = json.value
355
+ currentQuery.value = cloneDeep(json.value)
356
+ nextTick(() => {
357
+ alignJSON()
358
+ })
359
+ })
360
+ watch(isOpen, () => {
361
+ nextTick(() => {
362
+ alignJSON()
363
+ })
283
364
  })
284
365
 
285
366
  return {
@@ -288,11 +369,12 @@ export default defineComponent({
288
369
  showSaveDialog,
289
370
  stringifiedJSON,
290
371
  selectedOption,
291
- canDelete,
372
+ hasActiveFilter,
292
373
  alignJSON,
293
374
  onQuerySelect,
294
375
  newQueryName,
295
376
  showDeleteDialog,
377
+ selectOptions,
296
378
  search,
297
379
  onChange,
298
380
  saveQuery,
@@ -1,4 +1,4 @@
1
- import { DlSmartSearchInput } from './components'
1
+ import { DlSmartSearchInput, DlSmartSearchJsonEditorDialog } from './components'
2
2
  import DlSmartSearch from './DlSmartSearch.vue'
3
3
 
4
- export { DlSmartSearch, DlSmartSearchInput }
4
+ export { DlSmartSearch, DlSmartSearchInput, DlSmartSearchJsonEditorDialog }
@@ -50,12 +50,14 @@ import {
50
50
  Alias as DlSmartSearchAlias,
51
51
  Schema as DlSmartSearchSchema
52
52
  } from '../../../../hooks/use-suggestions'
53
+ import { DlSelectOption } from '../../types'
53
54
 
54
- type DlSmartSearchFilters = Filters & { [key: string]: any }
55
+ // type DlSmartSearchFilters = Filters & { [key: string]: any }
56
+ type DlSmartSearchFilter = DlSelectOption
55
57
 
56
58
  export type {
57
59
  DlSmartSearchAlias,
58
60
  DlSmartSearchSchema,
59
61
  ColorSchema as DlSmartSearchColorSchema,
60
- DlSmartSearchFilters
62
+ DlSmartSearchFilter
61
63
  }
@@ -740,10 +740,7 @@ export default defineComponent({
740
740
 
741
741
  this.selectedIndex = this.options.findIndex(
742
742
  (option: string | Record<string, string | number> | number) =>
743
- isEqual(
744
- (option as any).value,
745
- (this.modelValue as any).value
746
- )
743
+ isEqual(option, this.modelValue)
747
744
  )
748
745
  },
749
746
  getOptionValue(option: any) {
@@ -920,10 +917,7 @@ export default defineComponent({
920
917
  <style scoped lang="scss">
921
918
  .root-container {
922
919
  width: var(--dl-select-width);
923
- &--s {
924
- display: flex;
925
- align-items: center;
926
- }
920
+ &--s,
927
921
  &--small {
928
922
  display: flex;
929
923
  align-items: center;
@@ -938,9 +932,10 @@ export default defineComponent({
938
932
  align-items: center;
939
933
  color: var(--dl-color-lighter);
940
934
 
935
+ &--s,
941
936
  &--small {
942
- margin-right: 5px;
943
- margin-bottom: 0px;
937
+ margin-bottom: 0;
938
+ margin-right: 4px;
944
939
  }
945
940
  }
946
941
 
@@ -37,174 +37,144 @@ export default defineComponent({
37
37
  const lines = ref(false)
38
38
 
39
39
  const codeEditorValue = ref(
40
- 'import urllib3\n' +
41
- 'urllib3.disable_warnings()\n' +
42
- 'from base64 import b64encode\n' +
43
- 'import os\n' +
44
- 'import sys\n' +
45
- 'import json\n' +
46
- 'import getpass\n' +
47
- 'from optparse import OptionParser\n' +
48
- 'from datetime import datetime, timedelta\n' +
49
- 'import time\n' +
50
- 'from time import gmtime, strftime, strptime\n' +
51
- 'from operator import itemgetter, attrgetter\n' +
52
- 'from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest\n' +
53
- '\n' +
54
- '# Global Variables\n' +
55
- "VERSION = '2.0.0'\n" +
56
- "HEADER = 'Pure Storage Take FlashBlade Snapshot (' + VERSION + ')'\n" +
57
- "BANNER = ('=' * 132)\n" +
58
- 'DEBUG_FLAG = False\n' +
59
- 'VERBOSE_FLAG = False\n' +
60
- "COOKIE = ''\n" +
61
- '\n' +
62
- 'def parsecl():\n' +
63
- " usage = 'usage: %prog [options]'\n" +
64
- " version = '%prog ' + VERSION\n" +
65
- ' description = "This application has been developed using Pure Storage v1.12 RESTful Web Service interfaces. Developed and tested using Python 3.9.5 Please contact ron@purestorage.com for assistance."\n' +
66
- '\n' +
67
- ' parser = OptionParser(usage=usage, version=version, description=description)\n' +
68
- '\n' +
69
- '\n' +
70
- " parser.add_option('-d', '--debug',\n" +
71
- " action = 'store_true',\n" +
72
- " dest = 'DEBUG_FLAG',\n" +
73
- ' default = False,\n' +
74
- " help = 'Debug [default: %default]')\n" +
75
- ' \n' +
76
- " parser.add_option('-f', '--filesystem',\n" +
77
- " action = 'store',\n" +
78
- " type = 'string',\n" +
79
- " dest = 'fs',\n" +
80
- " help = 'FlashBlade File System')\n" +
81
- ' \n' +
82
- " parser.add_option('-r', '--replicant',\n" +
83
- " action = 'store',\n" +
84
- " type = 'string',\n" +
85
- " dest = 'flashBladeRep',\n" +
86
- " help = 'FlashBlade Replicant array')\n" +
87
- ' \n' +
88
- " parser.add_option('-s', '--server',\n" +
89
- " action = 'store',\n" +
90
- " type = 'string',\n" +
91
- " dest = 'flashBlade',\n" +
92
- " help = 'FlashBlade array')\n" +
93
- ' \n' +
94
- " parser.add_option('-t', '--token',\n" +
95
- " action = 'store',\n" +
96
- " type = 'string',\n" +
97
- " dest = 'API_TOKEN',\n" +
98
- " help = 'Pure API Token')\n" +
99
- '\n' +
100
- " parser.add_option('-S', '--suffix',\n" +
101
- " action = 'store',\n" +
102
- " type = 'string',\n" +
103
- " dest = 'suffix',\n" +
104
- " help = 'File system snapshot suffix')\n" +
105
- '\n' +
106
- " parser.add_option('-v', '--verbose',\n" +
107
- " action = 'store_true',\n" +
108
- " dest = 'VERBOSE_FLAG',\n" +
109
- ' default = False,\n' +
110
- " help = 'Verbose [default: %default]')\n" +
111
- '\n' +
112
- ' (options, args) = parser.parse_args()\n' +
113
- '\n' +
114
- " '''\n" +
115
- ' print("Options:", options)\n' +
116
- ' print("Args:", args)\n' +
117
- " '''\n" +
118
- ' \n' +
119
- ' return(options)\n' +
120
- '\n' +
121
- 'def main():\n' +
122
- ' # Setup variables\n' +
123
- ' global DEBUG_FLAG\n' +
124
- ' exit_code = 0\n' +
125
- '\n' +
126
- ' # Check for command line parameters\n' +
127
- ' options = parsecl()\n' +
128
- ' API_TOKEN = options.API_TOKEN\n' +
129
- ' flashBlade = options.flashBlade\n' +
130
- ' flashBladeRep = options.flashBladeRep\n' +
131
- ' fs = options.fs\n' +
132
- ' suffix = options.suffix\n' +
133
- ' DEBUG_FLAG = options.DEBUG_FLAG\n' +
134
- ' VERBOSE_FLAG = options.VERBOSE_FLAG\n' +
135
- ' \n' +
136
- ' if DEBUG_FLAG:\n' +
137
- " print('API Token:', API_TOKEN)\n" +
138
- " print('FlashBlade:', flashBlade)\n" +
139
- " print('Relplicant:', flashBladeRep)\n" +
140
- " print('File System:', fs)\n" +
141
- " print('Suffix:', suffix)\n" +
142
- " print('Debug Flag:', DEBUG_FLAG)\n" +
143
- " print('Verbose Flag:', VERBOSE_FLAG)\n" +
144
- '\n' +
145
- ' if flashBlade == None:\n' +
146
- " sys.exit('Exiting: You must provide FlashBlade details')\n" +
147
- ' \n' +
148
- ' if API_TOKEN == None:\n' +
149
- " sys.exit('Exiting: You must provide FlashBlade API Token details')\n" +
150
- '\n' +
151
- ' if fs == None:\n' +
152
- " sys.exit('Exiting: You must provide FlashBlade file system')\n" +
153
- '\n' +
154
- ' print(BANNER)\n' +
155
- " print(HEADER + ' - ' + flashBlade)\n" +
156
- " print(strftime('%d/%m/%Y %H:%M:%S %Z', gmtime()))\n" +
157
- ' print(BANNER)\n' +
158
- '\n' +
159
- ' # create PurityFb object for a certain array\n' +
160
- ' fb = PurityFb(flashBlade)\n' +
161
- ' # this is required for versions before Purity//FB 2.1.3 because they only supports self-signed\n' +
162
- ' # certificates. in later versions, this may be unnecessary if you have imported a certificate.\n' +
163
- ' fb.disable_verify_ssl()\n' +
164
- ' \n' +
165
- ' try:\n' +
166
- ' res= fb.login(API_TOKEN)\n' +
167
- ' except rest.ApiException as e:\n' +
168
- ' print("Exception when logging in to the array: %s\\n" % e)\n' +
169
- '\n' +
170
- ' if res:\n' +
171
- ' try:\n' +
172
- ' if flashBladeRep:\n' +
173
- ' if suffix:\n' +
174
- ' # create a snapshot with suffix and replicate to target array\n' +
175
- ' res = fb.file_system_snapshots.create_file_system_snapshots(sources=[fs],\n' +
176
- ' suffix=SnapshotSuffix(suffix),\n' +
177
- ' send=True,\n' +
178
- ' targets=[flashBladeRep])\n' +
179
- ' else:\n' +
180
- ' # create a snapshot without suffix and replicate to target array\n' +
181
- ' res = fb.file_system_snapshots.create_file_system_snapshots(sources=[fs],\n' +
182
- ' send=True,\n' +
183
- ' targets=[flashBladeRep])\n' +
184
- ' else:\n' +
185
- ' if suffix:\n' +
186
- ' # create a snapshot with suffix for the file system\n' +
187
- ' res = fb.file_system_snapshots.create_file_system_snapshots(sources=[fs],\n' +
188
- ' suffix=SnapshotSuffix(suffix))\n' +
189
- ' else:\n' +
190
- ' # create a snapshot without suffix for the file system\n' +
191
- ' res = fb.file_system_snapshots.create_file_system_snapshots(sources=[fs])\n' +
192
- ' \n' +
193
- ' if VERBOSE_FLAG:\n' +
194
- ' print(res)\n' +
195
- ' \n' +
196
- " print('Snapshot created for', fs, 'suffix', res.items[0].suffix) \n" +
197
- '\n' +
198
- ' except rest.ApiException as e:\n' +
199
- ' print("Exception when creating file system snapshots: %s\\n" % e) \n' +
200
- '\n' +
201
- ' fb.logout()\n' +
202
- ' print(BANNER)\n' +
203
- " print(strftime('%d/%m/%Y %H:%M:%S %Z', gmtime()))\n" +
204
- ' print(BANNER)\n' +
205
- ' sys.exit(exit_code)\n' +
206
- '\n' +
207
- 'main()'
40
+ `import getopt, sys, urllib, time
41
+
42
+ def main():
43
+
44
+ status = 0
45
+
46
+ # input arguments
47
+
48
+ try:
49
+ opts, args = getopt.getopt(sys.argv[1:],"h:iq",
50
+ ["help","invid=","quarter="])
51
+ except getopt.GetoptError:
52
+ usage()
53
+ tree = False
54
+ for o, a in opts:
55
+ if o in ("-h", "--help"):
56
+ usage()
57
+ if o in ("-i", "--invid"):
58
+ invid = str(a)
59
+ if o in ("-q", "--quarter"):
60
+ quarter = int(a)
61
+
62
+ kepid, invid, kepmag, mode, start, stop, release = GetMetaData(invid,quarter)
63
+
64
+ # convert Gregorian date to Julian date
65
+
66
+ def Greg2JD(year, month, day):
67
+
68
+ if (month < 3):
69
+ y = float(year) - 1.0
70
+ m = float(month) + 12.0
71
+ else:
72
+ y = float(year)
73
+ m = float(month)
74
+ a = 0; b = 0
75
+ if (y + m / 12 + float(day) / 365 > 1582.87166):
76
+ a = int(y / 100)
77
+ b = 2 - a + int(float(a / 4))
78
+ c = 0
79
+ if (y < 0.0):
80
+ c = int(365.25 * y - 0.75)
81
+ else:
82
+ c = int(365.25 * y)
83
+ d = int(30.6001 * (m + 1))
84
+ jd = float(b + c + d + day + 1720994.5);
85
+
86
+ return jd
87
+
88
+ # start and stop Julian dates for Kepler quarters
89
+
90
+ def QuarterDates(quarter):
91
+
92
+ Qstart = [2454953.5,2454964.5,2454998.5]
93
+ Qstop = [2454962.5,2454997.5,2455100.5]
94
+ if (quarter < len(Qstart)):
95
+ return Qstart[quarter] - 10, Qstop[quarter] + 10
96
+ else:
97
+ message = 'No spacecraft roll dates recorded for quarter ' + str(quarter) + '.\n'
98
+ message += 'Find an updated script at http://keplergo.arc.nasa.gov'
99
+ sys.exit(message)
100
+
101
+ def GetMetaData(invid,quarter):
102
+
103
+ # get start and stop dates for quarter
104
+
105
+ Qstart, Qstop = QuarterDates(quarter)
106
+
107
+ # URL for MAST data access
108
+
109
+ url = 'http://archive.stsci.edu/kepler/data_search/search.php?'
110
+ url += 'action=Search'
111
+ url += '&max_records=100000'
112
+ url += '&verb=3'
113
+ url += '&ktc_investigation_id=' + invid
114
+ url += '&ktc_target_type[]=LC'
115
+ url += '&ktc_target_type[]=SC'
116
+ url += '&outputformat=CSV'
117
+
118
+ # retrieve results from MAST
119
+
120
+ lines = urllib.urlopen(url)
121
+
122
+ # extract metadata from CSV
123
+
124
+ print '\n%4s %9s %7s %5s %2s %10s %10s %10s' % \
125
+ ('#', 'KepID', 'InvID', 'KpMag', 'Md', 'Start', 'Stop', 'Release')
126
+ kepid = []; invid = []; mode = []
127
+ ra = []; dec = []; kepmag = []
128
+ start = []; stop = []; release = []
129
+ for line in lines:
130
+ line = line.strip().split(',')
131
+ if (len(line[0]) > 0 and
132
+ 'Kepler' not in line[0] and
133
+ 'integer' not in line[0] and
134
+ 'no rows found' not in line[0]):
135
+ GregStart = line[7][:10].split('-')
136
+ GregStop = line[8][:10].split('-')
137
+ JDstart = Greg2JD(int(GregStart[0]),int(GregStart[1]),int(GregStart[2]))
138
+ JDstop = Greg2JD(int(GregStop[0]),int(GregStop[1]),int(GregStop[2]))
139
+ if (JDstart > Qstart and JDstop < Qstop):
140
+ kepid.append(line[0])
141
+ invid.append(line[1])
142
+ kepmag.append(float(line[22]))
143
+ mode.append(line[6])
144
+ ra.append(line[4])
145
+ dec.append(line[5])
146
+ start.append(line[7])
147
+ stop.append(line[8])
148
+ release.append(line[9])
149
+ print '%4d %9s %7s %5.2f %2s %10s %10s %10s' % \
150
+ (len(kepid), kepid[-1], invid[-1], kepmag[-1], mode[-1],
151
+ start[-1][:10], stop[-1][:10], release[-1][:10])
152
+ if (len(kepid) == 0):
153
+ print '\nNo data available as of ' + time.asctime(time.localtime())
154
+ else:
155
+ print '\n' + time.asctime(time.localtime())
156
+
157
+ return kepid, invid, kepmag, mode, start, stop, release
158
+
159
+ def usage():
160
+
161
+ print ' -------------------------------------------------------------------------'
162
+ print ' Martin Still (martin.d.still@nasa.gov) NASA Ames Nov 11, 2009'
163
+ print ' '
164
+ print ' Find all quarter data associated with an investigation ID within the MAST'
165
+ print ' archive.'
166
+ print ' '
167
+ print ' Typical usage:'
168
+ print ' KepInvestigationAtMAST.py --invid=GO10003 --quarter=1'
169
+ print ' '
170
+ print ' --invid Investigation ID number of GO program'
171
+ print ' --quarter Kepler quarter (integer number)'
172
+ print ' -------------------------------------------------------------------------'
173
+ sys.exit(' ')
174
+
175
+ #-------------------------------
176
+ if __name__ == "__main__":
177
+ main()`
208
178
  )
209
179
  const language = ref('python')
210
180
 
@@ -143,6 +143,43 @@
143
143
  </template>
144
144
  </dl-input>
145
145
  </div>
146
+
147
+ <p>input with tooltip and no title</p>
148
+ <div>
149
+ <dl-input
150
+ class="input-parts"
151
+ placeholder="Select option"
152
+ tooltip="test me tooltip"
153
+ >
154
+ <template #action>
155
+ <dl-button
156
+ dense
157
+ flat
158
+ icon="icon-dl-add"
159
+ size="m"
160
+ />
161
+ </template>
162
+ </dl-input>
163
+ </div>
164
+
165
+ <p>input with tooltip and no title size small</p>
166
+ <div>
167
+ <dl-input
168
+ class="input-parts"
169
+ placeholder="Select option"
170
+ tooltip="test me tooltip"
171
+ size="small"
172
+ >
173
+ <template #action>
174
+ <dl-button
175
+ dense
176
+ flat
177
+ icon="icon-dl-add"
178
+ size="m"
179
+ />
180
+ </template>
181
+ </dl-input>
182
+ </div>
146
183
  </div>
147
184
  </template>
148
185
  <script lang="ts">
@@ -426,6 +426,81 @@
426
426
  </div>
427
427
  </template>
428
428
  </dl-select>
429
+
430
+ Select with tooltip no title
431
+ <dl-select
432
+ v-model="selectedOption"
433
+ :options="[
434
+ {
435
+ subLabel: 'not so high',
436
+ label: 'High',
437
+ value: 'high',
438
+ bgColor: 'dl-color-negative'
439
+ },
440
+ {
441
+ subLabel: 'not so medium',
442
+ label: 'Medium',
443
+ value: 'medium',
444
+ bgColor: 'dl-color-warning',
445
+ textColor: 'dl-color-darker'
446
+ },
447
+ {
448
+ subLabel: 'not so low',
449
+ label: 'Low',
450
+ value: 'low',
451
+ bgColor: 'dl-color-positive',
452
+ textColor: 'dl-color-darker'
453
+ }
454
+ ]"
455
+ clearable
456
+ style="margin-bottom: 150px"
457
+ tooltip="test tooltip"
458
+ >
459
+ <template #option="scope">
460
+ <div style="padding: 5px 0px">
461
+ <div>{{ scope.opt.label }}</div>
462
+ <div>{{ scope.opt.subLabel }}</div>
463
+ </div>
464
+ </template>
465
+ </dl-select>
466
+
467
+ Select with tooltip no title size small
468
+ <dl-select
469
+ v-model="selectedOption"
470
+ :options="[
471
+ {
472
+ subLabel: 'not so high',
473
+ label: 'High',
474
+ value: 'high',
475
+ bgColor: 'dl-color-negative'
476
+ },
477
+ {
478
+ subLabel: 'not so medium',
479
+ label: 'Medium',
480
+ value: 'medium',
481
+ bgColor: 'dl-color-warning',
482
+ textColor: 'dl-color-darker'
483
+ },
484
+ {
485
+ subLabel: 'not so low',
486
+ label: 'Low',
487
+ value: 'low',
488
+ bgColor: 'dl-color-positive',
489
+ textColor: 'dl-color-darker'
490
+ }
491
+ ]"
492
+ clearable
493
+ style="margin-bottom: 150px"
494
+ size="small"
495
+ tooltip="test tooltip"
496
+ >
497
+ <template #option="scope">
498
+ <div style="padding: 5px 0px">
499
+ <div>{{ scope.opt.label }}</div>
500
+ <div>{{ scope.opt.subLabel }}</div>
501
+ </div>
502
+ </template>
503
+ </dl-select>
429
504
  </div>
430
505
  </template>
431
506
 
@@ -100,7 +100,7 @@ import {
100
100
  DlCheckbox,
101
101
  DlInput
102
102
  } from '../../components'
103
- import { DlSmartSearchFilters, Query } from '../../components/types'
103
+ import { DlSmartSearchFilter, Query } from '../../components/types'
104
104
  import { parseSmartQuery } from '../../utils'
105
105
 
106
106
  export default defineComponent({
@@ -195,29 +195,47 @@ export default defineComponent({
195
195
  key: 'metadata.system.width'
196
196
  }
197
197
  ]
198
+ const filters: DlSmartSearchFilter[] = [
199
+ {
200
+ label: 'Query 1',
201
+ value: { q: 1 }
202
+ },
203
+ {
204
+ label: 'Query 2',
205
+ value: { query2: 'query2' }
206
+ },
207
+ {
208
+ label: 'Query 3',
209
+ value: { query3: 'query3' }
210
+ },
211
+ {
212
+ label: 'Query 4',
213
+ value: { age: 12, name: 'john' }
214
+ }
215
+ ]
198
216
 
199
- const filters: DlSmartSearchFilters = {
200
- saved: [
201
- {
202
- name: 'Query 1',
203
- query: '{"q": 1}'
204
- },
205
- {
206
- name: 'Query 2',
207
- query: '{"query2": "query2"}'
208
- },
209
- {
210
- name: 'Query 3',
211
- query: '{"query3": "query3"}'
212
- },
213
- {
214
- name: 'Query 4',
215
- query: '{"age": 12, "name": "john"}'
216
- }
217
- ],
218
- recent: [],
219
- suggested: []
220
- }
217
+ // const filters: DlSmartSearchFilters = {
218
+ // saved: [
219
+ // {
220
+ // name: 'Query 1',
221
+ // query: {"q": 1}
222
+ // },
223
+ // {
224
+ // name: 'Query 2',
225
+ // query: {"query2": "query2"}
226
+ // },
227
+ // {
228
+ // name: 'Query 3',
229
+ // query: {"query3": "query3"}
230
+ // },
231
+ // {
232
+ // name: 'Query 4',
233
+ // query: {"age": 12, "name": "john"}
234
+ // }
235
+ // ],
236
+ // recent: [],
237
+ // suggested: []
238
+ // }
221
239
 
222
240
  return {
223
241
  schema,
@@ -249,27 +267,33 @@ export default defineComponent({
249
267
  this.isLoading = false
250
268
  }, 2000)
251
269
 
252
- if (this.filters.recent[-1]?.name !== queryString) {
253
- this.filters.recent.push({
254
- name: queryString || query.name,
255
- query: query.query
256
- })
257
- }
270
+ // if (this.filters.recent[-1]?.name !== queryString) {
271
+ // this.filters.recent.push({
272
+ // name: queryString || query.name,
273
+ // query: query.query
274
+ // })
275
+ // }
258
276
  },
259
- handleSaveQuery(query: Query, type: string) {
260
- const saveQueryIndex = this.filters[type].findIndex(
261
- (q: Query) => q.name === query.name || q.query === query.query
262
- )
263
- if (saveQueryIndex !== -1) {
264
- this.filters[type][saveQueryIndex] = query
265
- } else {
266
- this.filters[type].push(query)
267
- }
277
+ // handleSaveQuery(query: Query, type: string) {
278
+ // const saveQueryIndex = this.filters[type].findIndex(
279
+ // (q: Query) => q.name === query.name || q.query === query.query
280
+ // )
281
+ // if (saveQueryIndex !== -1) {
282
+ // this.filters[type][saveQueryIndex] = query
283
+ // } else {
284
+ // this.filters[type].push(query)
285
+ // }
286
+ // },
287
+ // handleRemoveQuery(query: Query, type: string) {
288
+ // this.filters[type] = this.filters[type].filter(
289
+ // (q: Query) => q.name !== query.name
290
+ // )
291
+ // },
292
+ handleSaveQuery(query: DlSmartSearchFilter) {
293
+ this.filters.push(query)
268
294
  },
269
- handleRemoveQuery(query: Query, type: string) {
270
- this.filters[type] = this.filters[type].filter(
271
- (q: Query) => q.name !== query.name
272
- )
295
+ handleRemoveQuery(query: DlSmartSearchFilter) {
296
+ this.filters = this.filters.filter((q) => q.label !== q.label)
273
297
  },
274
298
  onSearchEmitted(query: Query) {
275
299
  this.searchEmitted++