App.vue 5.03 KB
Newer Older
1
<template>
janis.streib's avatar
FMT    
janis.streib committed
2
3
4
5
6
  <div id="app">
    <Navbar/>
    <div id="wrapper" :class="$store.state.show_sidebar ? 'squished' : null">
      <div id="page-content-wrapper">
        <div class="container">
janis.streib's avatar
janis.streib committed
7
          <b-alert v-if="$sysinfo.host_oper_mode.is_devel" show variant="warning">
janis.streib's avatar
FMT    
janis.streib committed
8
9
10
11
12
            <b-row>
              <b-col cols="1" style="margin-top: auto; margin-bottom: auto" class="vertical-center">
                <font-awesome-icon :icon="['fas', 'dumpster-fire']" size="3x"></font-awesome-icon>
              </b-col>
              <b-col style="margin-top: auto; margin-bottom: auto">
janis.streib's avatar
janis.streib committed
13
14
                      <span><b> WIP!</b>
                        Diese Anwendung befindet sich in aktiver Entwicklung. Einige Features könnten eingeschränkt funktionieren oder unerwartete Ergebnisse liefern.</span>
janis.streib's avatar
FMT    
janis.streib committed
15
16
17
18
19
20
              </b-col>
            </b-row>
          </b-alert>
          <b-breadcrumb :items="breadcrumbs"/>
          <router-view v-bind:key="$store.state.reload_count"/>
          <Footer/>
21
        </div>
janis.streib's avatar
FMT    
janis.streib committed
22
23
24
25
      </div>
      <b-card id="sidebar-wrapper" no-body :class="$store.state.show_sidebar ? 'hide' : null">
        <Sidebar/>
      </b-card>
26
    </div>
janis.streib's avatar
janis.streib committed
27
    <b-modal content-class="text-center" centered id="net-suite-error" hide-footer hide-header size="lg">
janis.streib's avatar
janis.streib committed
28
29
30
      <h1>
        <font-awesome-icon icon="poo-storm" size="3x"></font-awesome-icon>
      </h1>
janis.streib's avatar
janis.streib committed
31
32
33
34
      <h3>Etwas ist schief gelaufen...</h3>
      <CopyField class="shadow" variant="danger"
                 :text="global_error"
                 multiline/>
35
36
37
38
39
      <hr/>
      <a target="_blank" href="https://git.scc.kit.edu/scc-net/netvs/netvs-core/issues">
        <font-awesome-icon icon="bug"/>
        Fehler melden</a> |
      Unterstützung für diese Anwendung und die API: <a href="mailto:netvs@scc.kit.edu">netvs∂scc.kit.edu</a>
janis.streib's avatar
janis.streib committed
40
    </b-modal>
janis.streib's avatar
FMT    
janis.streib committed
41
  </div>
42
43
44
</template>

<script>
janis.streib's avatar
janis.streib committed
45
import Navbar from './components/Navbar'
janis.streib's avatar
janis.streib committed
46
import CopyField from './components/CopyField'
janis.streib's avatar
janis.streib committed
47
48
import Footer from './components/Footer'
import Sidebar from './components/Sidebar'
janis.streib's avatar
janis.streib committed
49
import {EventBus} from '@/eventbus'
50

janis.streib's avatar
janis.streib committed
51
export default {
janis.streib's avatar
janis.streib committed
52
  components: {Sidebar, Footer, Navbar, CopyField},
janis.streib's avatar
FMT    
janis.streib committed
53
  data() {
janis.streib's avatar
janis.streib committed
54
    return {
janis.streib's avatar
janis.streib committed
55
      global_error: null,
janis.streib's avatar
janis.streib committed
56
57
58
59
      breadcrumbs: []
    }
  },
  watch: {
janis.streib's avatar
FMT    
janis.streib committed
60
    $route() {
janis.streib's avatar
janis.streib committed
61
62
63
64
65
66
      let m = this.$router.currentRoute.matched
      m = m[m.length - 1]
      this.breadcrumbs = this.getBreadcrumbs(m)
    }
  },
  methods: {
janis.streib's avatar
FMT    
janis.streib committed
67
68
    getBreadcrumbs(m) {
      const res = [{text: m.meta.resolveName(this.$route.params), path: m.path}]
janis.streib's avatar
janis.streib committed
69
70
71
72
73
74
75
      while ((m.meta && m.meta.resolveParents) || m.parent) {
        if (m.meta && m.meta.resolveParents) {
          const parents = m.meta.resolveParents(this.$route.params)
          for (let i = 0; i < parents.length; i++) {
            if (typeof parents[i] === 'object' && 'text' in parents[i] && 'to' in parents[i]) {
              res.unshift(parents[i])
              continue
76
            }
janis.streib's avatar
janis.streib committed
77
78
            m = this.$router.resolve(parents[i]).resolved.matched
            m = m[m.length - 1]
janis.streib's avatar
FMT    
janis.streib committed
79
            res.unshift({text: m.meta.resolveName(this.$route.params), to: parents[i]})
janis.streib's avatar
janis.streib committed
80
81
82
          }
        } else {
          m = m.parent
janis.streib's avatar
FMT    
janis.streib committed
83
          res.unshift({text: m.meta.resolveName(this.$route.params), to: m.path})
84
        }
janis.streib's avatar
janis.streib committed
85
86
      }
      return res
87
    }
janis.streib's avatar
janis.streib committed
88
  },
janis.streib's avatar
FMT    
janis.streib committed
89
  mounted() {
janis.streib's avatar
janis.streib committed
90
    window.console.log('%c ', `font-size:0px; padding: 200px; background:url(${window.location.protocol}//${window.location.hostname}:${window.location.port}/important.webp) no-repeat; background-position: center; background-size: contain;`)
janis.streib's avatar
janis.streib committed
91
92
93
94
    const self = this
    EventBus.$on('error', (payload) => {
      window.console.debug('evbus trigger')
      window.console.debug(payload)
janis.streib's avatar
janis.streib committed
95
      if ('response' in payload) {
janis.streib's avatar
janis.streib committed
96
97
98
        if (payload.response.status === 401) {
          return
        }
janis.streib's avatar
janis.streib committed
99
100
101
102
103
        self.global_error = payload.response.data
      } else {
        self.global_error = payload
      }
      self.global_error = JSON.stringify(self.global_error, null, 4)
janis.streib's avatar
janis.streib committed
104
105
      this.$bvModal.show('net-suite-error')
    })
janis.streib's avatar
janis.streib committed
106
107
  }
}
108
</script>
gj4210's avatar
gj4210 committed
109
110

<style lang="scss">
janis.streib's avatar
FMT    
janis.streib committed
111
112
113
114
115
@import '../node_modules/bootstrap/scss/bootstrap.scss';
@import '../node_modules/bootstrap-vue/dist/bootstrap-vue.css';
@import 'assets/css/net-suite.css';
@import 'assets/css/net-suite-devel.css';
@import 'assets/css/net-suite-test.css';
gj4210's avatar
gj4210 committed
116

janis.streib's avatar
FMT    
janis.streib committed
117
$sidebar-width: 380px;
gj4210's avatar
gj4210 committed
118

janis.streib's avatar
FMT    
janis.streib committed
119
120
121
122
@media screen and (min-width: 981px) {
  #wrapper {
    transition: padding-right .5s;
  }
gj4210's avatar
gj4210 committed
123

janis.streib's avatar
FMT    
janis.streib committed
124
125
126
  #wrapper.squished {
    padding-right: $sidebar-width;
  }
gj4210's avatar
gj4210 committed
127

janis.streib's avatar
FMT    
janis.streib committed
128
129
130
131
132
133
134
135
136
137
138
  #sidebar-wrapper {
    height: 100%;
    width: $sidebar-width;
    position: fixed;
    z-index: 1;
    top: 0;
    right: -$sidebar-width;
    transition: right .5s;
    padding-top: 50px;
    background: #F7F7F7;
  }
gj4210's avatar
gj4210 committed
139

janis.streib's avatar
FMT    
janis.streib committed
140
141
142
143
  #sidebar-wrapper.hide {
    right: 0px;
  }
}
gj4210's avatar
gj4210 committed
144

janis.streib's avatar
FMT    
janis.streib committed
145
146
147
148
149
150
151
152
153
154
155
@media screen and (max-width: 980px) {
  #sidebar-wrapper {
    height: 100%;
    width: 100%;
    position: fixed;
    z-index: 999;
    top: -100%;
    transition: top .5s;
    padding-top: 50px;
    background: #F7F7F7;
  }
gj4210's avatar
gj4210 committed
156

janis.streib's avatar
FMT    
janis.streib committed
157
158
159
160
  #sidebar-wrapper.hide {
    top: 0;
  }
}
161
162
163
164
165
166
167
168
169

.collapse-icon {
  transition: transform;
  transition-duration: 250ms;
}

.not-collapsed > .collapse-icon {
  transform: rotate(-180deg);
}
janis.streib's avatar
janis.streib committed
170
</style>