Skip to content
Snippets Groups Projects
Select Git revision
  • e2eb7dc646bb9413c414120402c2b7b368b14ac7
  • master default protected
  • replication_test
  • 559-i18n-labels-for-pids
  • 556-usage-statistics
  • 553-semantic-recommendation-2
  • release-1.10 protected
  • dev protected
  • 553-semantic-recommendation
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • v1.10.3 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
41 results

index.vue

  • index.vue 2.94 KiB
    <template>
      <div>
        <v-toolbar flat>
          <v-toolbar-title v-text="$t('databases.recent', { name: 'vue-i18n' })" />
          <v-spacer />
          <v-toolbar-title>
            <v-btn v-if="canCreateDatabase" color="primary" name="create-database" @click.stop="createDbDialog = true">
              <v-icon left>mdi-plus</v-icon> Database
            </v-btn>
          </v-toolbar-title>
        </v-toolbar>
        <v-card flat tile>
          <v-divider class="mx-4" />
          <v-card-text v-if="infoLinks && infoLinks.length > 0">
            <div class="mb-2">Important Links</div>
            <div class="text--primary">
              <ul>
                <li v-for="(link, i) in infoLinks" :key="i">
                  <a :href="link.href" :target="link.blank ? '_blank' : 'self'">
                    {{ link.text }} <sup v-if="link.blank"><v-icon color="primary" x-small>mdi-open-in-new</v-icon></sup>
                  </a>
                </li>
              </ul>
            </div>
          </v-card-text>
        </v-card>
        <DatabaseList ref="databases" :databases="databases" />
        <v-dialog
          v-model="createDbDialog"
          persistent
          max-width="640">
          <CreateDB @close="closed" />
        </v-dialog>
      </div>
    </template>
    
    <script>
    import DatabaseList from '@/components/DatabaseList'
    import CreateDB from '@/components/dialogs/CreateDB'
    import DatabaseService from '@/api/database.service'
    
    export default {
      components: {
        CreateDB,
        DatabaseList
      },
      data () {
        return {
          loading: false,
          createDbDialog: null,
          databases: []
        }
      },
      computed: {
        roles () {
          return this.$store.state.roles
        },
        canCreateDatabase () {
          if (!this.roles) {
            return false
          }
          return this.roles.includes('create-database')
        },
        infoLinks () {
          const infoLinks = this.$config.infoLinks
          console.debug('info links', infoLinks)
          return infoLinks
        },
        isFiltered () {
          return this.$route.query.f === 'my'
        }
      },
      mounted () {
        this.loadDatabases()
      },
      methods: {
        closed (event) {
          this.createDbDialog = false
          if (event.success) {
            this.$router.push('/database?f=my')
          }
        },
        loadDatabases () {
          this.loadingDatabases = true
          if (this.isFiltered) {
            DatabaseService.findAllOnlyAccess()
              .then((databases) => {
                this.databases = databases
                console.info('Found', this.databases.length, 'database(s) with access')
              })
              .catch(() => {
                this.loadingDatabases = false
              })
              .finally(() => {
                this.loadingDatabases = false
              })
          } else {
            DatabaseService.findAll()
              .then((databases) => {
                this.databases = databases
                console.info('Found', this.databases.length, 'database(s)')
              })
              .catch(() => {
                this.loadingDatabases = false
              })
              .finally(() => {
                this.loadingDatabases = false
              })
          }
        }
      }
    }
    </script>