JoinMicrocosm.vue 6.5 KB
Newer Older
Adam Procter's avatar
init  
Adam Procter committed
1
2
3
<template>
  <form>
    <span class="arrow">⬇⬇</span>
4

Adam Procter's avatar
init  
Adam Procter committed
5
6
7
8
    <h1>What shall we call you ? 👩‍🚀</h1>
    <p>
      First we need to connect this device to your ideas. This name is what
      allows you to create and edit your nodes and this name can be anything you
Adam Procter's avatar
Adam Procter committed
9
      like, this name is always anonymous. <strong>This is required.</strong>
Adam Procter's avatar
init  
Adam Procter committed
10
11
    </p>
    <div class="breaker-one">
Adam Procter's avatar
tidy up    
Adam Procter committed
12
      <label for="name">Your Name: {{ nameFormatted }}</label>
Adam Procter's avatar
Adam Procter committed
13
14
15
16
17
18
19
20
21
22
      <input
        v-model.trim="name"
        type="text"
        id="name"
        ref="name"
        placeholder="type name here!"
        autocorrect="off"
        autocapitalize="none"
        required
      />
Adam Procter's avatar
init  
Adam Procter committed
23
24
25
26
27
28
29
30
    </div>
    <h2>Next start or join a <span class="long">microcosm !</span> 🚀</h2>

    <p>
      Start your own microcosm to store your ideas and ask others to join you,
      either tell them the microcosm name or share the URL and add the ending;
      /microcosm/<strong>nameofyourmicrocosm</strong>
    </p>
Adam Procter's avatar
Adam Procter committed
31

Adam Procter's avatar
init  
Adam Procter committed
32
33
    <div class="breaker-two">
      <label for="microcosm">Microcosm:</label>
34

Adam Procter's avatar
init  
Adam Procter committed
35
      <input
Adam Procter's avatar
tidy up    
Adam Procter committed
36
37
        v-model.trim="microcosm"
        ref="microcosm"
Adam Procter's avatar
init  
Adam Procter committed
38
39
40
41
42
43
        type="text"
        id="microcosm"
        placeholder="type microcosm name here!"
        autocorrect="off"
        autocapitalize="none"
      />
Adam Procter's avatar
Adam Procter committed
44
      <p class="validation">{{ error }}</p>
45
      <router-link to="/collect">
Adam Procter's avatar
Adam Procter committed
46
        <button type="button" @click="setName(name), setMicrocosm()">
47
48
49
          Start or Join
        </button>
      </router-link>
Adam Procter's avatar
Adam Procter committed
50
51
52
      <button class="configButton" type="button" @click="settings = !settings">
        Change CouchDB Configuration
      </button>
Adam Procter's avatar
init  
Adam Procter committed
53
    </div>
Adam Procter's avatar
Adam Procter committed
54

Adam Procter's avatar
Adam Procter committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
    <template v-if="settings">
      <h2>Configure your own <span class="long">CouchDB !</span> 👩‍🔧</h2>

      <p>
        CouchDB is what allows you to sync nodes (your ideas) between your team.
        You need to have your own CouchDB set up. Otherwise leave this empty and
        you will continue to use the default cloud instance of CouchDB.
      </p>

      <div class="breaker-three">
        <label for="protocol"> Protocol:</label>
        <input
          v-model.trim="protocol"
          type="text"
          id="protocol"
          placeholder="type protocol here"
          autocorrect="off"
          autocapitalize="none"
        />

        <label for="protocol"> CouchDB username:</label>
        <input
          v-model.trim="username"
          type="text"
          id="username"
          placeholder="type CouchDB username here"
          autocorrect="off"
          autocapitalize="none"
        />

        <label for="protocol"> password:</label>
        <input
          v-model="password"
          type="password"
          id="password"
          placeholder="type password here"
          autocorrect="off"
          autocapitalize="none"
        />

        <label for="protocol"> URL:</label>
        <input
          v-model.trim="url"
          type="text"
          id="url"
          autocomplete="url"
          placeholder="type url here"
          autocorrect="off"
          autocapitalize="none"
        />

        <button
          type="button"
          @click="configureRemote(protocol, username, password, url)"
        >
          Save
        </button>
      </div>
    </template>
Adam Procter's avatar
init  
Adam Procter committed
114
115
116
117
118
  </form>
</template>

<script>
export default {
ap2x07's avatar
updates    
ap2x07 committed
119
120
  name: 'JoinMicrocosm',

Adam Procter's avatar
Adam Procter committed
121
122
123
124
125
126
127
128
  // directives: {
  //   focus: {
  //     mounted(el) {
  //       el.focus()
  //     },
  //   },
  // },

Adam Procter's avatar
Adam Procter committed
129
  data: function () {
ap2x07's avatar
updates    
ap2x07 committed
130
    return {
Adam Procter's avatar
Adam Procter committed
131
      error: '',
Adam Procter's avatar
tidy up    
Adam Procter committed
132
133
134
135
136
137
138
      // what you are calling yourself / device
      name: '',
      nameSet: false,
      nameFormatted: '',
      // Next dataset related to microcosm
      microcosm: '',
      microcosmSet: false,
Adam Procter's avatar
Adam Procter committed
139
      microcosmFormatted: '',
Adam Procter's avatar
Adam Procter committed
140
141
142
143
144
      settings: false,
      protocol: '',
      username: '',
      password: '',
      url: '',
Adam Procter's avatar
tidy up    
Adam Procter committed
145
146
147
148
    }
  },

  methods: {
Adam Procter's avatar
Adam Procter committed
149
    setName(name) {
150
      // format name so no spaces or dashes PouchDB/ CouchDB doesn't like them
Adam Procter's avatar
tidy up    
Adam Procter committed
151
152
153
      var lowercasename = this.name.toLowerCase()
      var spacesremoved = lowercasename.split(' ').join('')
      this.nameFormatted = spacesremoved.split('-').join('')
Adam Procter's avatar
Adam Procter committed
154
155
156
157
158
      if (name == '') {
        this.error = 'Please set your name above first ☺️'
      } else {
        this.nameSet = true
      }
Adam Procter's avatar
tidy up    
Adam Procter committed
159
160
161
162
      localStorage.setItem('nogg_name', this.nameFormatted)
    },

    setMicrocosm() {
Adam Procter's avatar
Adam Procter committed
163
164
      if (this.nameSet == true) {
        this.$router.push({ path: '/collect' })
165
        // format microcosm so no spaces or dashes PouchDB/ CouchDB doesn't like them
Adam Procter's avatar
Adam Procter committed
166
167
168
169
170
171
172
173
174
175
176
        var lowercasemicrocosm = this.microcosm.toLowerCase()
        var spacesremoved = lowercasemicrocosm.split(' ').join('')
        this.microcosmFormatted = spacesremoved.split('-').join('')
        this.microcosmSet = true
        localStorage.setItem('nogg_microcosm', this.microcosmFormatted)
        // now we sent this same data set to the store
        var devicename = this.nameFormatted
        var microcosm = this.microcosmFormatted
        this.$store.dispatch('setMicrocosm', { devicename, microcosm })
        this.$store.dispatch('startDB')
      }
Adam Procter's avatar
tidy up    
Adam Procter committed
177
    },
Adam Procter's avatar
Adam Procter committed
178

Adam Procter's avatar
Adam Procter committed
179
180
181
182
183
184
185
186
187
    configureRemote(protocol, username, password, url) {
      // console.log(protocol, username, password, url)
      this.$store.dispatch('configureRemote', {
        protocol,
        username,
        password,
        url,
      })
    },
Adam Procter's avatar
Adam Procter committed
188
  },
ap2x07's avatar
updates    
ap2x07 committed
189
}
Adam Procter's avatar
init  
Adam Procter committed
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1 {
  margin-top: -0.5em;
  font-size: 5.2em;
  line-height: 1.2em;
}

h2 {
  font-size: 5.2em;
  line-height: 1.2em;
  margin: -0.5em 0 0 0;
  padding: 0em;
  font-family: houschka-rounded, sans-serif;
  font-weight: 700;
  font-style: normal;
  color: black;
}

Adam Procter's avatar
Adam Procter committed
211
212
213
214
215
216
.validation {
  font-weight: 700;
  font-style: bold;
  color: rgb(104, 39, 255);
}

Adam Procter's avatar
init  
Adam Procter committed
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
.arrow {
  font-size: 6em;
  color: #1cc469;
}

.breaker-one {
  padding: 1em;
  margin-left: -1em;
  margin-right: -0.4em;
  margin-bottom: 2.5em;
  background-color: rgba(196, 47, 152, 0.4);
}

.breaker-two {
  padding: 1em;
  margin-left: -1em;
  margin-right: -0.4em;
Adam Procter's avatar
Adam Procter committed
234
  margin-bottom: 2.5em;
Adam Procter's avatar
init  
Adam Procter committed
235
236
237
  background-color: rgba(37, 194, 194, 0.4);
}

Adam Procter's avatar
Adam Procter committed
238
239
240
241
242
243
244
245
.breaker-three {
  padding: 1em;
  margin-left: -1em;
  margin-right: -0.4em;
  margin-bottom: 1em;
  background-color: rgba(196, 47, 152, 0.4);
}

Adam Procter's avatar
init  
Adam Procter committed
246
247
248
249
250
251
252
253
254
255
256
257
label,
button {
  display: block;
}

input {
  margin-top: 0.8em;
  border: none;
  padding: 1em;
  font-size: 1em;
}
button {
Adam Procter's avatar
Adam Procter committed
258
  display: block;
Adam Procter's avatar
init  
Adam Procter committed
259
260
261
262
263
264
265
  cursor: pointer;
  background-color: #1cc469;
  border: none;
  margin-top: 1em;
  padding: 1em;
  font-size: 1em;
}
Adam Procter's avatar
Adam Procter committed
266
267
268
.configButton {
  background-color: rgba(196, 47, 152, 0.4);
}
Adam Procter's avatar
init  
Adam Procter committed
269
</style>