git ssb

2+

mixmix / ticktack



Tree: e828eb68d13e6361f6c31b66a89a0b880ec6f257

Files: e828eb68d13e6361f6c31b66a89a0b880ec6f257 / ftu / app.js

2384 bytesRaw
1const { h, Value, when } = require('mutant')
2const nest = require('depnest')
3const path = require('path')
4const fs = require('fs')
5const { remote } = require('electron')
6const insertCss = require('insert-css')
7const values = require('lodash/values')
8const electron = require('electron')
9
10
11exports.gives = nest('ftu.app')
12
13exports.needs = nest({
14 'styles.css': 'reduce',
15 'translations.sync.strings': 'first'
16})
17
18exports.create = (api) => {
19 return nest({
20 'ftu.app': function app() {
21
22 const strings = api.translations.sync.strings()
23
24 const css = values(api.styles.css()).join('\n')
25 insertCss(css)
26
27 var isBusy = Value(false)
28
29 var actionButtons = h('section', [
30 h('div.left', h('Button', strings.backup.ftu.importAction)),
31 h('div.right', h('Button', { 'ev-click': () => actionCreateNewOne(isBusy) }, strings.backup.ftu.createAction))
32 ])
33
34 var busyMessage = h('p', strings.backup.ftu.busyMessage)
35
36 var app = h('App', [
37 h('Header', [
38 windowControls()
39 ]),
40 h('Page -ftu', [
41 h('div.content', [
42 h('h1', strings.backup.ftu.welcomeHeader),
43 h('p', strings.backup.ftu.welcomeMessage),
44 when(isBusy, busyMessage, actionButtons)
45 ])
46 ])
47 ])
48
49 return app
50 }
51
52 })
53
54}
55
56function actionCreateNewOne(isBusy) {
57 isBusy.set(true)
58 const config = require('../config').create().config.sync.load()
59 const manifest = JSON.parse(fs.readFileSync(path.join(__dirname, "../manifest.json")))
60 fs.writeFileSync(path.join(config.path, 'manifest.json'), JSON.stringify(manifest))
61
62
63 electron.ipcRenderer.send('create-new-identity')
64}
65
66function windowControls() {
67 if (process.platform === 'darwin') return
68
69 const window = remote.getCurrentWindow()
70 const minimize = () => window.minimize()
71 const maximize = () => {
72 if (!window.isMaximized()) window.maximize()
73 else window.unmaximize()
74 }
75 const close = () => window.close()
76
77 return h('div.window-controls', [
78 h('img.min', {
79 src: assetPath('minimize.png'),
80 'ev-click': minimize
81 }),
82 h('img.max', {
83 src: assetPath('maximize.png'),
84 'ev-click': maximize
85 }),
86 h('img.close', {
87 src: assetPath('close.png'),
88 'ev-click': close
89 })
90 ])
91}
92
93
94function assetPath(name) {
95 return path.join(__dirname, '../assets', name)
96}
97

Built with git-ssb-web