LoginApp.vue 9.58 KB
Newer Older
RWTH App's avatar
RWTH App committed
1
<template>
2
  <div id="wrap" :style="cssProps">
Marcel Nellesen's avatar
Marcel Nellesen committed
3
4
5
    <RWTHHeader
      :rwthImage="rwthImage"
      :coscineImageBlack="coscineImageBlack"/>
6
    <div class="container-fluid app-content">
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
7
8
9
10
11
      <div class="row">
        <div class="col-xl-2"></div>
        <div class="col-xl-8">
          <h1 class="headline">
            {{ $t('headline') }}
12
            <img class="logo" :src="coscineImageBlue" v-if="imageEnabled" alt />
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
13
14
            <span class="keyword">CoScInE</span>
          </h1>
Marcel Nellesen's avatar
Marcel Nellesen committed
15
          <div v-if="!tos" class="row">
16
            <div class="col-sm-12 col-md-7">
17
18
19
              <div class="alert alert-warning" role="alert">
                <h5 class="alert-heading">{{ $t('alert_headline') }}</h5>
                <p class="alert-title">{{ $t('alert_text1') }}
20
21
                  <a href="mailto:servicedesk@itc.rwth-aachen.de?subject=CoScInE%20Pilot%20Program">Servicedesk</a>
                  {{ $t('alert_text2') }}
22
23
24
25
26
27
                </p>
              </div>
              <div class="card bg-light mb-3 w-100">
                <div class="card-body">
                  <p class="card-text">
                    <vue-markdown :source="news"></vue-markdown>
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
28
                  </p>
29
30
31
                </div>
              </div>
            </div>
32
            <div class="col-sm-12 col-md-5">
33
34
35
36
              <div class="row">
                <div class="card bg-light mb-3 w-100">
                  <div class="card-body">
                    <transition name="component-fade" mode="out-in">
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
37
                      <component
38
                        :is="(logoutState) ? logoutComponent : currentInputCard"
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
39
                        :returnUrl="this.returnUrl"
40
                        :shibbolethReturnUrl="this.shibbolethReturnUrl"
41
42
                        :idpUrl="this.idpUrl"
                        :loggedInWithShibboleth="this.loggedInWithShibboleth"
43
                        :mergeReturnUrl="mergeReturnUrl"
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
44
                        @back="loginBack"
45
                        @clickGetORCiDForm="getORCiDForm"
46
                        @changeLogoutState="changeLogoutState"
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
47
                      />
48
49
50
51
                    </transition>
                  </div>
                </div>
              </div>
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
52
53
54
55
56
57
              <div class="row">
                <button
                  hidden
                  class="btn btn-secondary dropdown-toggle w-100"
                  id="signup-toggle"
                >{{ $t('signup') }}</button>
58
              </div>
59
60
61
62
63
64
65
66
67
68
69
70
71
              <div class="row">
                <div class="card bg-light mb-3 w-100">
                  <div class="card-body">
                    <h5 class="card-title">{{ $t('description_headline') }}</h5>
                    <p class="card-text">{{ $t('description_text') }}</p>
                    <h5 class="card-title">{{ $t('description_help_headline') }}</h5>
                    <p class="card-text">
                      {{ $t('description_help') }}
                      <a href="mailto:servicedesk@itc.rwth-aachen.de">Servicedesk</a>
                    </p>
                  </div>
                </div>
              </div>
72
73
            </div>
          </div>
Marcel Nellesen's avatar
Marcel Nellesen committed
74
75
76
77
78
79
          <div v-else class="row">
            <div class="col-sm-12 col-md-12">
              <TOS
                :tosReturnUrl="this.tosReturnUrl"
                />
            </div>
80
          </div>
Marcel Nellesen's avatar
Marcel Nellesen committed
81
        </div>
82
83
      </div>
      <div class="col-xl-2"></div>
84
    </div>   
Marcel Nellesen's avatar
Marcel Nellesen committed
85
    <RWTHFooter/>
RWTH App's avatar
RWTH App committed
86
87
88
89
90
  </div>
</template>

<script lang="ts">
import Vue from 'vue';
91
import VueMarkdown from 'vue-markdown';
92
import LoginMain from './components/LoginMain.vue';
93
import LogoutMain from './components/LogoutMain.vue';
Marcel Nellesen's avatar
Marcel Nellesen committed
94
95
96
import TOS from './components/TOS.vue';
import RWTHHeader from './components/RWTHHeader.vue';
import RWTHFooter from './components/RWTHFooter.vue';
97

98
99
import coscineImageBlackPath from './assets/logo-coscine-black.png';
import coscineImageBluePath from './assets/logo-coscine-blue.png';
100
101
102
103
104
import rwthImagePath from './assets/logo-rwth.png';
import linkWhitePath from './assets/link_white.svg';
import mailGreyPath from './assets/mail_grey.svg';
import phoneGreyPath from './assets/phone_grey.svg';
import faxGreyPath from './assets/fax_grey.svg';
105

106
107
import { NoticeApi } from '@coscine/api-connection';

Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
108
let scriptPath = '';
109
let imageEnabled = false;
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
110
111
if (document.currentScript !== undefined) {
  scriptPath = (document.currentScript as any).src as string;
112
  imageEnabled = true;
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
113
114
}
const scriptUrl = (scriptPath === '') ? '/' : scriptPath.substring(0, scriptPath.indexOf('app.js'));
115
const rootUrl = (scriptPath.indexOf('/js') !== -1) ? scriptUrl.replace('/js', '') : scriptUrl;
116

117
function getReturnUrlParam() {
118
  const hookupElement = document.getElementById('loginpage');
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
119
120
  const returnUrlParameters =
    hookupElement != null ? hookupElement.getAttribute('returnUrl') : '';
121
122
123
124
  return returnUrlParameters;
}

function getReturnUrl(method: string) {
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
125
  const returnUrl = encodeURI(
126
    '/coscine/api/Coscine.Api.STS/' + method + '/login?returnUrl=' + getReturnUrlParam(),
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
127
  );
128
129
  return returnUrl;
}
RWTH App's avatar
RWTH App committed
130

131
132
133
134
function getMergeReturnUrl() {
  return getReturnUrl('Merge');
}

Marcel Nellesen's avatar
Marcel Nellesen committed
135
136
137
138
function getTOSReturnUrl() {
  return encodeURI('' + getReturnUrlParam());
}

139
140
141
142
function getAccountReturnUrl() {
  return getReturnUrl('Account');
}

143
function getShibbolethReturnUrl() {
144
145
146
147
  return getReturnUrl('Shibboleth');
}

function getIdpUrl() {
148
  const hookupElement = document.getElementById('loginpage');
149
150
151
  const idpUrl =
    hookupElement != null ? hookupElement.getAttribute('IdpUrl') : '';
  return idpUrl;
152
153
}

154
155
156
157
158
159
160
161
function getORCiDUrl() {
  const hookupElement = document.getElementById('loginpage');
  const orcidUrlString =
    (hookupElement != null ? hookupElement.getAttribute('orcidUrl') : '') as string;
  const orcidUrl = encodeURI(orcidUrlString);
  return orcidUrl;
}

162
163
164
165
166
function getIsLogout() {
  const urlParams = new URLSearchParams(window.location.search);
  return urlParams.has('logout');
}

Marcel Nellesen's avatar
Marcel Nellesen committed
167
168
169
170
171
function getIsTOS() {
  const urlParams = new URLSearchParams(window.location.search);
  return urlParams.has('tos');
}

172
173
174
175
176
function getLoggedInWithShibboleth() {
  const urlParams = new URLSearchParams(window.location.search);
  return urlParams.has('loggedInWithShibboleth');
}

RWTH App's avatar
RWTH App committed
177
export default Vue.extend({
178
  name: 'loginapp',
RWTH App's avatar
RWTH App committed
179
  components: {
180
    LoginMain,
181
    LogoutMain,
Marcel Nellesen's avatar
Marcel Nellesen committed
182
183
184
    TOS,
    RWTHHeader,
    RWTHFooter,
185
    VueMarkdown,
186
  },
187
188
189
  computed: {
    cssProps() {
      return {
190
191
192
193
        '--linkWhite': 'url(' + rootUrl + linkWhitePath + ') 1px 9px no-repeat',
        '--mailGrey': 'url(' + rootUrl + mailGreyPath + ') 0px 6px no-repeat',
        '--phoneGrey': 'url(' + rootUrl + phoneGreyPath + ') 0px 6px no-repeat',
        '--faxGrey': 'url(' + rootUrl + faxGreyPath + ') 0px 6px no-repeat',
194
195
196
      };
    },
  },
197
198
  data() {
    return {
199
200
      coscineImageBlack: rootUrl + coscineImageBlackPath,
      coscineImageBlue: rootUrl + coscineImageBluePath,
201
      rwthImage: rootUrl + rwthImagePath,
202
      imageEnabled,
203
      returnUrl: getAccountReturnUrl(),
204
      shibbolethReturnUrl: getShibbolethReturnUrl(),
Marcel Nellesen's avatar
Marcel Nellesen committed
205
      tosReturnUrl: getTOSReturnUrl(),
206
      mergeReturnUrl: getMergeReturnUrl(),
207
      idpUrl: getIdpUrl(),
208
      orcidUrl: getORCiDUrl(),
209
210
      logoutState: getIsLogout(),
      loggedInWithShibboleth: getLoggedInWithShibboleth(),
211
      currentInputCard: 'LoginMain',
212
      logoutComponent: 'LogoutMain',
Marcel Nellesen's avatar
Marcel Nellesen committed
213
      tos: getIsTOS(),
214
      news: '',
215
216
    };
  },
217
218
219
220
221
  watch: {
    '$i18n.locale'() {
      this.retrieveNotices();
    },
  },
222
  methods: {
223
224
225
226
227
228
229
    retrieveNotices() {
      NoticeApi.getNotices('changelog', this.$i18n.locale, (response: any) => {
        let splitArray = response.data.data.body.split(/\s(?:#{3})\s/g, 5);
        splitArray = splitArray.join('### ');
        this.news = splitArray.toString();
      });
    },
230
231
232
    loginBack() {
      this.currentInputCard = 'LoginMain';
    },
233
234
235
    getORCiDForm() {
      window.location.href = this.orcidUrl;
    },
236
237
238
    changeLogoutState() {
      this.logoutState = !this.logoutState;
    },
RWTH App's avatar
RWTH App committed
239
  },
240
241
242
  created() {
    this.retrieveNotices();
  },
RWTH App's avatar
RWTH App committed
243
244
245
246
});
</script>

<style>
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287

.list-group-item-action {
  background: var(--linkWhite)!important;
}

#mail.list-group-item-action{
  background: var(--mailGrey)!important;
}
#phone.list-group-item {
  background: var(--phoneGrey)!important;
}
#fax.list-group-item {
  background: var(--faxGrey)!important;
}

#wrap .navbar .lang {
  padding-top: .5rem!important;
}

.siteIcon {
  height: 0px;
  width: 0px;
  overflow: visible;
  margin-left: 150px;
  line-height: 0px;
  margin-top: -20px;
}

.coscineSiteIcon {
  height: 0px;
  width: 0px;
  overflow: visible;
  line-height: 0px;        
}

.coscineSiteIcon img {
  margin-left: 8px;
  height: 36px;
  width: 36px;
}

288
289
290
291
292
293
.coscineSiteIcon img {
  margin-left: 8px;
  height: 36px;
  width: 36px;
}

294
295
296
297
298
299
300
301
302
303
304
.coscineSiteIconLabel {
  margin-left: 8px;
  vertical-align: middle;
  color: white;
  font-size: 22px;
}

.navbar .app-header-container a img.ms-siteicon-img {
  border: 0px;
}

RWTH App's avatar
RWTH App committed
305
#app {
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
306
  font-family: "Avenir", Helvetica, Arial, sans-serif;
RWTH App's avatar
RWTH App committed
307
308
309
310
311
312
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
313
314
315
316

.headline {
  text-align: left;
  padding-left: 0.4em;
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
317
  margin-bottom: 1em;
318
319
320
321
322
323
324
325
}

.logo {
  width: 1.5em;
  margin: 0.15em;
}

.keyword {
Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
326
  color: #00549f;
327
328
329
330
331
332
333
}

.card-title {
  text-align: left;
  padding: 0em 0.2em;
}

Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
334
.card-text {
335
336
337
338
  text-align: left;
  padding: 0em 0.4em;
}

Benedikt Heinrichs's avatar
Benedikt Heinrichs committed
339
340
341
.component-fade-enter-active,
.component-fade-leave-active {
  transition: opacity 0.3s ease;
342
343
344
345
346
347
348
349
350
351
}

.component-fade-enter, .component-fade-leave-to
/* .component-fade-leave-active below version 2.1.8 */ {
  opacity: 0;
}

#signup-toggle {
  margin: 0em;
}
352
353
354
355
356
357
358
359
360

.alert-heading {
  text-align: left;
  border-radius: .2rem;
}
.alert-title {
  text-align: left;
  border-radius: .2rem;
}
RWTH App's avatar
RWTH App committed
361
</style>