solid-ui 2.4.18 → 2.4.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/lib/acl/acl.d.ts.map +1 -1
- package/lib/acl/acl.js +2 -4
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.d.ts.map +1 -1
- package/lib/acl/add-agent-buttons.js +5 -5
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/chat/bookmarks.js +20 -22
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +13 -15
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +10 -10
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +14 -16
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +19 -23
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +16 -21
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +24 -24
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.d.ts.map +1 -1
- package/lib/create/create.js +9 -9
- package/lib/create/create.js.map +1 -1
- package/lib/folders.js +2 -6
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +4 -4
- package/lib/footer/index.js.map +1 -1
- package/lib/header/index.d.ts.map +1 -1
- package/lib/header/index.js +11 -8
- package/lib/header/index.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +30 -28
- package/lib/index.js.map +1 -1
- package/lib/login/login.d.ts +130 -0
- package/lib/login/login.d.ts.map +1 -0
- package/lib/login/login.js +1415 -0
- package/lib/login/login.js.map +1 -0
- package/lib/matrix/matrix.js +2 -2
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/messageArea.js +9 -10
- package/lib/messageArea.js.map +1 -1
- package/lib/pad.js +2 -2
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +4 -5
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +8 -8
- package/lib/preferences.js.map +1 -1
- package/lib/{authn → signup}/config-default.js +0 -0
- package/lib/signup/config-default.js.map +1 -0
- package/lib/{authn → signup}/signup.js +0 -0
- package/lib/signup/signup.js.map +1 -0
- package/lib/table.js +2 -3
- package/lib/table.js.map +1 -1
- package/lib/tabs.js +3 -3
- package/lib/tabs.js.map +1 -1
- package/lib/utils/index.js +6 -6
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +4 -5
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +8230 -24429
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons.js +16 -16
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +2 -2
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +7 -10
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts +1 -1
- package/lib/widgets/forms/autocomplete/publicData.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +15 -16
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts +1 -1
- package/lib/widgets/forms/basic.d.ts.map +1 -1
- package/lib/widgets/forms/basic.js +2 -2
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.d.ts +1 -1
- package/lib/widgets/forms/comment.js +3 -3
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js +2 -2
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/formStyle.js +3 -3
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +10 -10
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/peoplePicker.js +2 -2
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/package.json +12 -4
- package/lib/authn/authSession.d.ts +0 -4
- package/lib/authn/authSession.d.ts.map +0 -1
- package/lib/authn/authSession.js +0 -25
- package/lib/authn/authSession.js.map +0 -1
- package/lib/authn/authn.d.ts +0 -193
- package/lib/authn/authn.d.ts.map +0 -1
- package/lib/authn/authn.js +0 -2238
- package/lib/authn/authn.js.map +0 -1
- package/lib/authn/config-default.js.map +0 -1
- package/lib/authn/index.d.ts +0 -35
- package/lib/authn/index.d.ts.map +0 -1
- package/lib/authn/index.js +0 -44
- package/lib/authn/index.js.map +0 -1
- package/lib/authn/signup.js.map +0 -1
- package/lib/authn/types.d.ts +0 -25
- package/lib/authn/types.d.ts.map +0 -1
- package/lib/authn/types.js +0 -6
- package/lib/authn/types.js.map +0 -1
- package/lib/logic.d.ts +0 -8
- package/lib/logic.d.ts.map +0 -1
- package/lib/logic.js +0 -79
- package/lib/logic.js.map +0 -1
|
@@ -0,0 +1,1415 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.ensureLoadedPreferences = ensureLoadedPreferences;
|
|
11
|
+
exports.ensureLoadedProfile = ensureLoadedProfile;
|
|
12
|
+
exports.ensureLoggedIn = ensureLoggedIn;
|
|
13
|
+
exports.filterAvailablePanes = filterAvailablePanes;
|
|
14
|
+
exports.findAppInstances = findAppInstances;
|
|
15
|
+
exports.getUserRoles = getUserRoles;
|
|
16
|
+
exports.loginStatusBox = loginStatusBox;
|
|
17
|
+
exports.newAppInstance = newAppInstance;
|
|
18
|
+
exports.registrationControl = registrationControl;
|
|
19
|
+
exports.registrationList = registrationList;
|
|
20
|
+
exports.renderSignInPopup = renderSignInPopup;
|
|
21
|
+
exports.selectWorkspace = selectWorkspace;
|
|
22
|
+
|
|
23
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
24
|
+
|
|
25
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
26
|
+
|
|
27
|
+
var _rdflib = require("rdflib");
|
|
28
|
+
|
|
29
|
+
var _solidLogic = require("solid-logic");
|
|
30
|
+
|
|
31
|
+
var debug = _interopRequireWildcard(require("../debug"));
|
|
32
|
+
|
|
33
|
+
var _log = require("../log");
|
|
34
|
+
|
|
35
|
+
var ns = _interopRequireWildcard(require("../ns.js"));
|
|
36
|
+
|
|
37
|
+
var _signup = require("../signup/signup.js");
|
|
38
|
+
|
|
39
|
+
var _style = require("../style");
|
|
40
|
+
|
|
41
|
+
var _index = require("../utils/index");
|
|
42
|
+
|
|
43
|
+
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
44
|
+
|
|
45
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
46
|
+
|
|
47
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Signing in, signing up, profile and preferences reloading
|
|
51
|
+
* Type index management
|
|
52
|
+
*
|
|
53
|
+
* Many functions in this module take a context object which
|
|
54
|
+
* holds various RDF symbols, add to it, and return a promise of it.
|
|
55
|
+
*
|
|
56
|
+
* * `me` RDF symbol for the user's WebID
|
|
57
|
+
* * `publicProfile` The user's public profile, iff loaded
|
|
58
|
+
* * `preferencesFile` The user's personal preference file, iff loaded
|
|
59
|
+
* * `index.public` The user's public type index file
|
|
60
|
+
* * `index.private` The user's private type index file
|
|
61
|
+
*
|
|
62
|
+
* Not RDF symbols:
|
|
63
|
+
* * `noun` A string in english for the type of thing -- like "address book"
|
|
64
|
+
* * `instance` An array of nodes which are existing instances
|
|
65
|
+
* * `containers` An array of nodes of containers of instances
|
|
66
|
+
* * `div` A DOM element where UI can be displayed
|
|
67
|
+
* * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages
|
|
68
|
+
* @packageDocumentation
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Resolves with the logged in user's WebID
|
|
73
|
+
*
|
|
74
|
+
* @param context
|
|
75
|
+
*/
|
|
76
|
+
// used to be logIn
|
|
77
|
+
function ensureLoggedIn(context) {
|
|
78
|
+
var me = _solidLogic.authn.currentUser();
|
|
79
|
+
|
|
80
|
+
if (me) {
|
|
81
|
+
_solidLogic.authn.saveUser(me, context);
|
|
82
|
+
|
|
83
|
+
return Promise.resolve(context);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return new Promise(function (resolve) {
|
|
87
|
+
_solidLogic.authn.checkUser().then(function (webId) {
|
|
88
|
+
// Already logged in?
|
|
89
|
+
if (webId) {
|
|
90
|
+
debug.log("logIn: Already logged in as ".concat(webId));
|
|
91
|
+
return resolve(context);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!context.div || !context.dom) {
|
|
95
|
+
return resolve(context);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var box = loginStatusBox(context.dom, function (webIdUri) {
|
|
99
|
+
_solidLogic.authn.saveUser(webIdUri, context);
|
|
100
|
+
|
|
101
|
+
resolve(context); // always pass growing context
|
|
102
|
+
});
|
|
103
|
+
context.div.appendChild(box);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Loads preference file
|
|
109
|
+
* Do this after having done log in and load profile
|
|
110
|
+
*
|
|
111
|
+
* @private
|
|
112
|
+
*
|
|
113
|
+
* @param context
|
|
114
|
+
*/
|
|
115
|
+
// used to be logInLoadPreferences
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
function ensureLoadedPreferences(_x2) {
|
|
119
|
+
return _ensureLoadedPreferences.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Logs the user in and loads their WebID profile document into the store
|
|
123
|
+
*
|
|
124
|
+
* @param context
|
|
125
|
+
*
|
|
126
|
+
* @returns Resolves with the context after login / fetch
|
|
127
|
+
*/
|
|
128
|
+
// used to be logInLoadProfile
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
function _ensureLoadedPreferences() {
|
|
132
|
+
_ensureLoadedPreferences = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(context) {
|
|
133
|
+
var statusArea, progressDisplay, complain, preferencesFile, m2;
|
|
134
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
135
|
+
while (1) {
|
|
136
|
+
switch (_context4.prev = _context4.next) {
|
|
137
|
+
case 0:
|
|
138
|
+
complain = function _complain(message) {
|
|
139
|
+
message = "ensureLoadedPreferences: ".concat(message);
|
|
140
|
+
|
|
141
|
+
if (statusArea) {
|
|
142
|
+
// statusArea.innerHTML = ''
|
|
143
|
+
statusArea.appendChild(widgets.errorMessageBlock(context.dom, message));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
debug.log(message); // reject(new Error(message))
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
if (!context.preferencesFile) {
|
|
150
|
+
_context4.next = 3;
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return _context4.abrupt("return", Promise.resolve(context));
|
|
155
|
+
|
|
156
|
+
case 3:
|
|
157
|
+
// already done
|
|
158
|
+
statusArea = context.statusArea || context.div || null;
|
|
159
|
+
_context4.prev = 4;
|
|
160
|
+
_context4.next = 7;
|
|
161
|
+
return ensureLoadedProfile(context);
|
|
162
|
+
|
|
163
|
+
case 7:
|
|
164
|
+
context = _context4.sent;
|
|
165
|
+
_context4.next = 10;
|
|
166
|
+
return _solidLogic.solidLogicSingleton.loadPreferences(context.me);
|
|
167
|
+
|
|
168
|
+
case 10:
|
|
169
|
+
preferencesFile = _context4.sent;
|
|
170
|
+
|
|
171
|
+
if (progressDisplay) {
|
|
172
|
+
progressDisplay.parentNode.removeChild(progressDisplay);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
context.preferencesFile = preferencesFile;
|
|
176
|
+
_context4.next = 48;
|
|
177
|
+
break;
|
|
178
|
+
|
|
179
|
+
case 15:
|
|
180
|
+
_context4.prev = 15;
|
|
181
|
+
_context4.t0 = _context4["catch"](4);
|
|
182
|
+
|
|
183
|
+
if (!(_context4.t0 instanceof _solidLogic.UnauthorizedError)) {
|
|
184
|
+
_context4.next = 22;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
m2 = 'Ooops - you are not authenticated (properly logged in) to for me to read your preference file. Try loggin out and logging in?';
|
|
189
|
+
(0, _log.alert)(m2);
|
|
190
|
+
_context4.next = 48;
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
case 22:
|
|
194
|
+
if (!(_context4.t0 instanceof _solidLogic.CrossOriginForbiddenError)) {
|
|
195
|
+
_context4.next = 28;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
m2 = "Unauthorized: Assuming preference file blocked for origin ".concat(window.location.origin);
|
|
200
|
+
context.preferencesFileError = m2;
|
|
201
|
+
return _context4.abrupt("return", context);
|
|
202
|
+
|
|
203
|
+
case 28:
|
|
204
|
+
if (!(_context4.t0 instanceof _solidLogic.SameOriginForbiddenError)) {
|
|
205
|
+
_context4.next = 33;
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
|
|
210
|
+
debug.warn(m2);
|
|
211
|
+
_context4.next = 48;
|
|
212
|
+
break;
|
|
213
|
+
|
|
214
|
+
case 33:
|
|
215
|
+
if (!(_context4.t0 instanceof _solidLogic.NotFoundError)) {
|
|
216
|
+
_context4.next = 42;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (!confirm("You do not currently have a preference file. OK for me to create an empty one? ".concat(_context4.t0.preferencesFile || ''))) {
|
|
221
|
+
_context4.next = 39;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// @@@ code me ... weird to have a name of the file but no file
|
|
226
|
+
(0, _log.alert)("Sorry; I am not prepared to do this. Please create an empty file at ".concat(_context4.t0.preferencesFile || '(?)'));
|
|
227
|
+
complain(new Error('Sorry; no code yet to create a preference file at '));
|
|
228
|
+
_context4.next = 40;
|
|
229
|
+
break;
|
|
230
|
+
|
|
231
|
+
case 39:
|
|
232
|
+
throw new Error("User declined to create a preference file at ".concat(_context4.t0.preferencesFile || '(?)'));
|
|
233
|
+
|
|
234
|
+
case 40:
|
|
235
|
+
_context4.next = 48;
|
|
236
|
+
break;
|
|
237
|
+
|
|
238
|
+
case 42:
|
|
239
|
+
if (!(_context4.t0 instanceof _solidLogic.FetchError)) {
|
|
240
|
+
_context4.next = 47;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
m2 = "Strange: Error ".concat(_context4.t0.status, " trying to read your preference file.").concat(_context4.t0.message);
|
|
245
|
+
(0, _log.alert)(m2);
|
|
246
|
+
_context4.next = 48;
|
|
247
|
+
break;
|
|
248
|
+
|
|
249
|
+
case 47:
|
|
250
|
+
throw new Error("(via loadPrefs) ".concat(_context4.t0));
|
|
251
|
+
|
|
252
|
+
case 48:
|
|
253
|
+
return _context4.abrupt("return", context);
|
|
254
|
+
|
|
255
|
+
case 49:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context4.stop();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}, _callee4, null, [[4, 15]]);
|
|
261
|
+
}));
|
|
262
|
+
return _ensureLoadedPreferences.apply(this, arguments);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function ensureLoadedProfile(_x3) {
|
|
266
|
+
return _ensureLoadedProfile.apply(this, arguments);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Returns promise of context with arrays of symbols
|
|
270
|
+
*
|
|
271
|
+
* 2016-12-11 change to include forClass arc a la
|
|
272
|
+
* https://github.com/solid/solid/blob/main/proposals/data-discovery.md
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
function _ensureLoadedProfile() {
|
|
277
|
+
_ensureLoadedProfile = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(context) {
|
|
278
|
+
var logInContext;
|
|
279
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
280
|
+
while (1) {
|
|
281
|
+
switch (_context5.prev = _context5.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
if (!context.publicProfile) {
|
|
284
|
+
_context5.next = 2;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return _context5.abrupt("return", context);
|
|
289
|
+
|
|
290
|
+
case 2:
|
|
291
|
+
_context5.prev = 2;
|
|
292
|
+
_context5.next = 5;
|
|
293
|
+
return ensureLoggedIn(context);
|
|
294
|
+
|
|
295
|
+
case 5:
|
|
296
|
+
logInContext = _context5.sent;
|
|
297
|
+
|
|
298
|
+
if (logInContext.me) {
|
|
299
|
+
_context5.next = 8;
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
throw new Error('Could not log in');
|
|
304
|
+
|
|
305
|
+
case 8:
|
|
306
|
+
_context5.next = 10;
|
|
307
|
+
return _solidLogic.solidLogicSingleton.loadProfile(logInContext.me);
|
|
308
|
+
|
|
309
|
+
case 10:
|
|
310
|
+
context.publicProfile = _context5.sent;
|
|
311
|
+
_context5.next = 17;
|
|
312
|
+
break;
|
|
313
|
+
|
|
314
|
+
case 13:
|
|
315
|
+
_context5.prev = 13;
|
|
316
|
+
_context5.t0 = _context5["catch"](2);
|
|
317
|
+
|
|
318
|
+
if (context.div && context.dom) {
|
|
319
|
+
context.div.appendChild(widgets.errorMessageBlock(context.dom, _context5.t0.message));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
throw new Error("Can't log in: ".concat(_context5.t0));
|
|
323
|
+
|
|
324
|
+
case 17:
|
|
325
|
+
return _context5.abrupt("return", context);
|
|
326
|
+
|
|
327
|
+
case 18:
|
|
328
|
+
case "end":
|
|
329
|
+
return _context5.stop();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}, _callee5, null, [[2, 13]]);
|
|
333
|
+
}));
|
|
334
|
+
return _ensureLoadedProfile.apply(this, arguments);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function findAppInstances(_x4, _x5, _x6) {
|
|
338
|
+
return _findAppInstances.apply(this, arguments);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* UI to control registration of instance
|
|
342
|
+
*/
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
function _findAppInstances() {
|
|
346
|
+
_findAppInstances = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(context, theClass, isPublic) {
|
|
347
|
+
var visibility, index, thisIndex, registrations, instances, containers, unique, e, i, cont;
|
|
348
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
349
|
+
while (1) {
|
|
350
|
+
switch (_context6.prev = _context6.next) {
|
|
351
|
+
case 0:
|
|
352
|
+
unique = function _unique(arr) {
|
|
353
|
+
return Array.from(new Set(arr));
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
if (!(isPublic === undefined)) {
|
|
357
|
+
_context6.next = 7;
|
|
358
|
+
break;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
_context6.next = 4;
|
|
362
|
+
return findAppInstances(context, theClass, true);
|
|
363
|
+
|
|
364
|
+
case 4:
|
|
365
|
+
_context6.next = 6;
|
|
366
|
+
return findAppInstances(context, theClass, false);
|
|
367
|
+
|
|
368
|
+
case 6:
|
|
369
|
+
return _context6.abrupt("return", context);
|
|
370
|
+
|
|
371
|
+
case 7:
|
|
372
|
+
_context6.prev = 7;
|
|
373
|
+
_context6.next = 10;
|
|
374
|
+
return isPublic ? ensureLoadedProfile(context) : ensureLoadedPreferences(context);
|
|
375
|
+
|
|
376
|
+
case 10:
|
|
377
|
+
_context6.next = 15;
|
|
378
|
+
break;
|
|
379
|
+
|
|
380
|
+
case 12:
|
|
381
|
+
_context6.prev = 12;
|
|
382
|
+
_context6.t0 = _context6["catch"](7);
|
|
383
|
+
widgets.complain(context, "loadIndex: login and load problem ".concat(_context6.t0));
|
|
384
|
+
|
|
385
|
+
case 15:
|
|
386
|
+
// console.log('awaited LogInLoad!', context)
|
|
387
|
+
visibility = isPublic ? 'public' : 'private';
|
|
388
|
+
_context6.prev = 16;
|
|
389
|
+
_context6.next = 19;
|
|
390
|
+
return (0, _solidLogic.loadIndex)(context, isPublic);
|
|
391
|
+
|
|
392
|
+
case 19:
|
|
393
|
+
_context6.next = 24;
|
|
394
|
+
break;
|
|
395
|
+
|
|
396
|
+
case 21:
|
|
397
|
+
_context6.prev = 21;
|
|
398
|
+
_context6.t1 = _context6["catch"](16);
|
|
399
|
+
debug.error(_context6.t1);
|
|
400
|
+
|
|
401
|
+
case 24:
|
|
402
|
+
index = context.index;
|
|
403
|
+
thisIndex = index[visibility];
|
|
404
|
+
registrations = thisIndex.map(function (ix) {
|
|
405
|
+
return _solidLogic.solidLogicSingleton.store.each(undefined, ns.solid('forClass'), theClass, ix);
|
|
406
|
+
}).reduce(function (acc, curr) {
|
|
407
|
+
return acc.concat(curr);
|
|
408
|
+
}, []);
|
|
409
|
+
instances = registrations.map(function (reg) {
|
|
410
|
+
return _solidLogic.solidLogicSingleton.store.each(reg, ns.solid('instance'));
|
|
411
|
+
}).reduce(function (acc, curr) {
|
|
412
|
+
return acc.concat(curr);
|
|
413
|
+
}, []);
|
|
414
|
+
containers = registrations.map(function (reg) {
|
|
415
|
+
return _solidLogic.solidLogicSingleton.store.each(reg, ns.solid('instanceContainer'));
|
|
416
|
+
}).reduce(function (acc, curr) {
|
|
417
|
+
return acc.concat(curr);
|
|
418
|
+
}, []);
|
|
419
|
+
context.instances = context.instances || [];
|
|
420
|
+
context.instances = unique(context.instances.concat(instances));
|
|
421
|
+
context.containers = context.containers || [];
|
|
422
|
+
context.containers = unique(context.containers.concat(containers));
|
|
423
|
+
|
|
424
|
+
if (containers.length) {
|
|
425
|
+
_context6.next = 35;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return _context6.abrupt("return", context);
|
|
430
|
+
|
|
431
|
+
case 35:
|
|
432
|
+
_context6.prev = 35;
|
|
433
|
+
_context6.next = 38;
|
|
434
|
+
return _solidLogic.solidLogicSingleton.load(containers);
|
|
435
|
+
|
|
436
|
+
case 38:
|
|
437
|
+
_context6.next = 45;
|
|
438
|
+
break;
|
|
439
|
+
|
|
440
|
+
case 40:
|
|
441
|
+
_context6.prev = 40;
|
|
442
|
+
_context6.t2 = _context6["catch"](35);
|
|
443
|
+
e = new Error("[FAI] Unable to load containers".concat(_context6.t2));
|
|
444
|
+
debug.log(e); // complain
|
|
445
|
+
|
|
446
|
+
widgets.complain(context, "Error looking for ".concat(_index.utils.label(theClass), ": ").concat(_context6.t2)); // but then ignore it
|
|
447
|
+
// throw new Error(e)
|
|
448
|
+
|
|
449
|
+
case 45:
|
|
450
|
+
i = 0;
|
|
451
|
+
|
|
452
|
+
case 46:
|
|
453
|
+
if (!(i < containers.length)) {
|
|
454
|
+
_context6.next = 56;
|
|
455
|
+
break;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
cont = containers[i];
|
|
459
|
+
_context6.t3 = context.instances;
|
|
460
|
+
_context6.next = 51;
|
|
461
|
+
return _solidLogic.solidLogicSingleton.getContainerMembers(cont.value);
|
|
462
|
+
|
|
463
|
+
case 51:
|
|
464
|
+
_context6.t4 = _context6.sent.map(function (uri) {
|
|
465
|
+
return _solidLogic.solidLogicSingleton.store.sym(uri);
|
|
466
|
+
});
|
|
467
|
+
context.instances = _context6.t3.concat.call(_context6.t3, _context6.t4);
|
|
468
|
+
|
|
469
|
+
case 53:
|
|
470
|
+
i++;
|
|
471
|
+
_context6.next = 46;
|
|
472
|
+
break;
|
|
473
|
+
|
|
474
|
+
case 56:
|
|
475
|
+
return _context6.abrupt("return", context);
|
|
476
|
+
|
|
477
|
+
case 57:
|
|
478
|
+
case "end":
|
|
479
|
+
return _context6.stop();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}, _callee6, null, [[7, 12], [16, 21], [35, 40]]);
|
|
483
|
+
}));
|
|
484
|
+
return _findAppInstances.apply(this, arguments);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function registrationControl(context, instance, theClass) {
|
|
488
|
+
var dom = context.dom;
|
|
489
|
+
|
|
490
|
+
if (!dom || !context.div) {
|
|
491
|
+
return Promise.resolve();
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
var box = dom.createElement('div');
|
|
495
|
+
context.div.appendChild(box);
|
|
496
|
+
return (0, _solidLogic.ensureTypeIndexes)(context).then(function () {
|
|
497
|
+
box.innerHTML = '<table><tbody><tr></tr><tr></tr></tbody></table>'; // tbody will be inserted anyway
|
|
498
|
+
|
|
499
|
+
box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid gray 0.05em;');
|
|
500
|
+
var tbody = box.children[0].children[0];
|
|
501
|
+
var form = new _rdflib.BlankNode(); // @@ say for now
|
|
502
|
+
|
|
503
|
+
var registrationStatements = function registrationStatements(index) {
|
|
504
|
+
var registrations = _solidLogic.solidLogicSingleton.getRegistrations(instance, theClass);
|
|
505
|
+
|
|
506
|
+
var reg = registrations.length ? registrations[0] : widgets.newThing(index);
|
|
507
|
+
return [(0, _rdflib.st)(reg, ns.solid('instance'), instance, index), (0, _rdflib.st)(reg, ns.solid('forClass'), theClass, index)];
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
var index, statements;
|
|
511
|
+
|
|
512
|
+
if (context.index && context.index["public"] && context.index["public"].length > 0) {
|
|
513
|
+
index = context.index["public"][0];
|
|
514
|
+
statements = registrationStatements(index);
|
|
515
|
+
tbody.children[0].appendChild(widgets.buildCheckBoxForm(context.dom, _solidLogic.solidLogicSingleton.store, "Public link to this ".concat(context.noun), null, statements, form, index));
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
if (context.index && context.index["private"] && context.index["private"].length > 0) {
|
|
519
|
+
index = context.index["private"][0];
|
|
520
|
+
statements = registrationStatements(index);
|
|
521
|
+
tbody.children[1].appendChild(widgets.buildCheckBoxForm(context.dom, _solidLogic.solidLogicSingleton.store, "Personal note of this ".concat(context.noun), null, statements, form, index));
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
return context;
|
|
525
|
+
}, function (e) {
|
|
526
|
+
var msg;
|
|
527
|
+
|
|
528
|
+
if (context.div && context.preferencesFileError) {
|
|
529
|
+
msg = '(Preferences not available)';
|
|
530
|
+
context.div.appendChild(dom.createElement('p')).textContent = msg;
|
|
531
|
+
} else if (context.div) {
|
|
532
|
+
msg = "registrationControl: Type indexes not available: ".concat(e);
|
|
533
|
+
context.div.appendChild(widgets.errorMessageBlock(context.dom, e));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
debug.log(msg);
|
|
537
|
+
})["catch"](function (e) {
|
|
538
|
+
var msg = "registrationControl: Error making panel: ".concat(e);
|
|
539
|
+
|
|
540
|
+
if (context.div) {
|
|
541
|
+
context.div.appendChild(widgets.errorMessageBlock(context.dom, e));
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
debug.log(msg);
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* UI to List at all registered things
|
|
549
|
+
*/
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
function registrationList(context, options) {
|
|
553
|
+
var dom = context.dom;
|
|
554
|
+
var div = context.div;
|
|
555
|
+
var box = dom.createElement('div');
|
|
556
|
+
div.appendChild(box);
|
|
557
|
+
return (0, _solidLogic.ensureTypeIndexes)(context).then(function (_indexes) {
|
|
558
|
+
box.innerHTML = '<table><tbody></tbody></table>'; // tbody will be inserted anyway
|
|
559
|
+
|
|
560
|
+
box.setAttribute('style', 'font-size: 120%; text-align: right; padding: 1em; border: solid #eee 0.5em;');
|
|
561
|
+
var table = box.firstChild;
|
|
562
|
+
var ix = [];
|
|
563
|
+
var sts = [];
|
|
564
|
+
var vs = ['private', 'public'];
|
|
565
|
+
vs.forEach(function (visibility) {
|
|
566
|
+
if (context.index && options[visibility]) {
|
|
567
|
+
ix = ix.concat(context.index[visibility][0]);
|
|
568
|
+
sts = sts.concat(_solidLogic.solidLogicSingleton.store.statementsMatching(undefined, ns.solid('instance'), undefined, context.index[visibility][0]));
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
var _loop = function _loop(i) {
|
|
573
|
+
var statement = sts[i];
|
|
574
|
+
|
|
575
|
+
if (options.type) {
|
|
576
|
+
// now check terms:forClass
|
|
577
|
+
if (!_solidLogic.solidLogicSingleton.store.holds(statement.subject, ns.solid('forClass'), options.type, statement.why)) {
|
|
578
|
+
return "continue"; // skip irrelevant ones
|
|
579
|
+
}
|
|
580
|
+
} // const cla = statement.subject
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
var inst = statement.object;
|
|
584
|
+
table.appendChild(widgets.personTR(dom, ns.solid('instance'), inst, {
|
|
585
|
+
deleteFunction: function deleteFunction(_x) {
|
|
586
|
+
if (!_solidLogic.solidLogicSingleton.store.updater) {
|
|
587
|
+
throw new Error('Cannot delete this, store has no updater');
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
_solidLogic.solidLogicSingleton.store.updater.update([statement], [], function (uri, ok, errorBody) {
|
|
591
|
+
if (ok) {
|
|
592
|
+
debug.log("Removed from index: ".concat(statement.subject));
|
|
593
|
+
} else {
|
|
594
|
+
debug.log("Error: Cannot delete ".concat(statement, ": ").concat(errorBody));
|
|
595
|
+
}
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}));
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
for (var i = 0; i < sts.length; i++) {
|
|
602
|
+
var _ret = _loop(i);
|
|
603
|
+
|
|
604
|
+
if (_ret === "continue") continue;
|
|
605
|
+
} // registrationList
|
|
606
|
+
|
|
607
|
+
/*
|
|
608
|
+
//const containers = solidLogicSingleton.store.each(theClass, ns.solid('instanceContainer'));
|
|
609
|
+
if (containers.length) {
|
|
610
|
+
fetcher.load(containers).then(function(xhrs){
|
|
611
|
+
for (const i=0; i<containers.length; i++) {
|
|
612
|
+
const cont = containers[i];
|
|
613
|
+
instances = instances.concat(solidLogicSingleton.store.each(cont, ns.ldp('contains')));
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
return context;
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function getDefaultSignInButtonStyle() {
|
|
625
|
+
return 'padding: 1em; border-radius:0.5em; font-size: 100%;';
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* Bootstrapping identity
|
|
629
|
+
* (Called by `loginStatusBox()`)
|
|
630
|
+
*
|
|
631
|
+
* @param dom
|
|
632
|
+
* @param setUserCallback
|
|
633
|
+
*
|
|
634
|
+
* @returns
|
|
635
|
+
*/
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
function signInOrSignUpBox(dom, setUserCallback) {
|
|
639
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
640
|
+
options = options || {};
|
|
641
|
+
var signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle(); // @@ TODO Remove the need to cast HTML element to any
|
|
642
|
+
|
|
643
|
+
var box = dom.createElement('div');
|
|
644
|
+
var magicClassName = 'SolidSignInOrSignUpBox';
|
|
645
|
+
debug.log('widgets.signInOrSignUpBox');
|
|
646
|
+
box.setUserCallback = setUserCallback;
|
|
647
|
+
box.setAttribute('class', magicClassName);
|
|
648
|
+
box.style = 'display:flex;'; // @@ fix all typecasts like this
|
|
649
|
+
// Sign in button with PopUP
|
|
650
|
+
|
|
651
|
+
var signInPopUpButton = dom.createElement('input'); // multi
|
|
652
|
+
|
|
653
|
+
box.appendChild(signInPopUpButton);
|
|
654
|
+
signInPopUpButton.setAttribute('type', 'button');
|
|
655
|
+
signInPopUpButton.setAttribute('value', 'Log in');
|
|
656
|
+
signInPopUpButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #eef;"));
|
|
657
|
+
|
|
658
|
+
_solidLogic.authSession.onLogin(function () {
|
|
659
|
+
var me = _solidLogic.authn.currentUser(); // const sessionInfo = authSession.info
|
|
660
|
+
// if (sessionInfo && sessionInfo.isLoggedIn) {
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
if (me) {
|
|
664
|
+
// const webIdURI = sessionInfo.webId
|
|
665
|
+
var webIdURI = me.uri; // setUserCallback(webIdURI)
|
|
666
|
+
|
|
667
|
+
var divs = dom.getElementsByClassName(magicClassName);
|
|
668
|
+
debug.log("Logged in, ".concat(divs.length, " panels to be serviced")); // At the same time, satisfy all the other login boxes
|
|
669
|
+
|
|
670
|
+
for (var i = 0; i < divs.length; i++) {
|
|
671
|
+
var div = divs[i]; // @@ TODO Remove the need to manipulate HTML elements
|
|
672
|
+
|
|
673
|
+
if (div.setUserCallback) {
|
|
674
|
+
try {
|
|
675
|
+
div.setUserCallback(webIdURI);
|
|
676
|
+
var parent = div.parentNode;
|
|
677
|
+
|
|
678
|
+
if (parent) {
|
|
679
|
+
parent.removeChild(div);
|
|
680
|
+
}
|
|
681
|
+
} catch (e) {
|
|
682
|
+
debug.log("## Error satisfying login box: ".concat(e));
|
|
683
|
+
div.appendChild(widgets.errorMessageBlock(dom, e));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
signInPopUpButton.addEventListener('click', function () {
|
|
691
|
+
var offline = (0, _solidLogic.offlineTestID)();
|
|
692
|
+
if (offline) return setUserCallback(offline.uri);
|
|
693
|
+
renderSignInPopup(dom);
|
|
694
|
+
}, false); // Sign up button
|
|
695
|
+
|
|
696
|
+
var signupButton = dom.createElement('input');
|
|
697
|
+
box.appendChild(signupButton);
|
|
698
|
+
signupButton.setAttribute('type', 'button');
|
|
699
|
+
signupButton.setAttribute('value', 'Sign Up for Solid');
|
|
700
|
+
signupButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #efe;"));
|
|
701
|
+
signupButton.addEventListener('click', function (_event) {
|
|
702
|
+
var signupMgr = new _signup.Signup();
|
|
703
|
+
signupMgr.signup().then(function (uri) {
|
|
704
|
+
debug.log('signInOrSignUpBox signed up ' + uri);
|
|
705
|
+
setUserCallback(uri);
|
|
706
|
+
});
|
|
707
|
+
}, false);
|
|
708
|
+
return box;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
function renderSignInPopup(dom) {
|
|
712
|
+
/**
|
|
713
|
+
* Issuer Menu
|
|
714
|
+
*/
|
|
715
|
+
var issuerPopup = dom.createElement('div');
|
|
716
|
+
issuerPopup.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center;');
|
|
717
|
+
dom.body.appendChild(issuerPopup);
|
|
718
|
+
var issuerPopupBox = dom.createElement('div');
|
|
719
|
+
issuerPopupBox.setAttribute('style', "\n background-color: white;\n box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -webkit-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -moz-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n -o-box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.2);\n border-radius: 4px;\n min-width: 400px;\n padding: 10px;\n ");
|
|
720
|
+
issuerPopup.appendChild(issuerPopupBox);
|
|
721
|
+
var issuerPopupBoxTopMenu = dom.createElement('div');
|
|
722
|
+
issuerPopupBoxTopMenu.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: space-between;\n ");
|
|
723
|
+
issuerPopupBox.appendChild(issuerPopupBoxTopMenu);
|
|
724
|
+
var issuerPopupBoxLabel = dom.createElement('label');
|
|
725
|
+
issuerPopupBoxLabel.setAttribute('style', 'margin-right: 5px; font-weight: 800');
|
|
726
|
+
issuerPopupBoxLabel.innerText = 'Select an identity provider';
|
|
727
|
+
var issuerPopupBoxCloseButton = dom.createElement('button');
|
|
728
|
+
issuerPopupBoxCloseButton.innerHTML = '<img src="https://solid.github.io/solid-ui/src/icons/noun_1180156.svg" style="width: 2em; height: 2em;" title="Cancel">';
|
|
729
|
+
issuerPopupBoxCloseButton.setAttribute('style', 'background-color: transparent; border: none;');
|
|
730
|
+
issuerPopupBoxCloseButton.addEventListener('click', function () {
|
|
731
|
+
issuerPopup.remove();
|
|
732
|
+
});
|
|
733
|
+
issuerPopupBoxTopMenu.appendChild(issuerPopupBoxLabel);
|
|
734
|
+
issuerPopupBoxTopMenu.appendChild(issuerPopupBoxCloseButton);
|
|
735
|
+
|
|
736
|
+
var loginToIssuer = /*#__PURE__*/function () {
|
|
737
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(issuerUri) {
|
|
738
|
+
var preLoginRedirectHash;
|
|
739
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
740
|
+
while (1) {
|
|
741
|
+
switch (_context.prev = _context.next) {
|
|
742
|
+
case 0:
|
|
743
|
+
_context.prev = 0;
|
|
744
|
+
// Save hash
|
|
745
|
+
preLoginRedirectHash = new URL(window.location.href).hash;
|
|
746
|
+
|
|
747
|
+
if (preLoginRedirectHash) {
|
|
748
|
+
window.localStorage.setItem('preLoginRedirectHash', preLoginRedirectHash);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
window.localStorage.setItem('loginIssuer', issuerUri); // Login
|
|
752
|
+
|
|
753
|
+
_context.next = 6;
|
|
754
|
+
return _solidLogic.authSession.login({
|
|
755
|
+
redirectUrl: window.location.href,
|
|
756
|
+
oidcIssuer: issuerUri
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
case 6:
|
|
760
|
+
_context.next = 11;
|
|
761
|
+
break;
|
|
762
|
+
|
|
763
|
+
case 8:
|
|
764
|
+
_context.prev = 8;
|
|
765
|
+
_context.t0 = _context["catch"](0);
|
|
766
|
+
(0, _log.alert)(_context.t0.message);
|
|
767
|
+
|
|
768
|
+
case 11:
|
|
769
|
+
case "end":
|
|
770
|
+
return _context.stop();
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}, _callee, null, [[0, 8]]);
|
|
774
|
+
}));
|
|
775
|
+
|
|
776
|
+
return function loginToIssuer(_x7) {
|
|
777
|
+
return _ref.apply(this, arguments);
|
|
778
|
+
};
|
|
779
|
+
}();
|
|
780
|
+
/**
|
|
781
|
+
* Text-based idp selection
|
|
782
|
+
*/
|
|
783
|
+
|
|
784
|
+
|
|
785
|
+
var issuerTextContainer = dom.createElement('div');
|
|
786
|
+
issuerTextContainer.setAttribute('style', "\n border-bottom: 1px solid #DDD;\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");
|
|
787
|
+
var issuerTextInputContainer = dom.createElement('div');
|
|
788
|
+
issuerTextInputContainer.setAttribute('style', "\n display: flex;\n flex-direction: row;\n ");
|
|
789
|
+
var issuerTextLabel = dom.createElement('label');
|
|
790
|
+
issuerTextLabel.innerText = 'Enter the URL of your identity provider:';
|
|
791
|
+
issuerTextLabel.setAttribute('style', 'color: #888');
|
|
792
|
+
var issuerTextInput = dom.createElement('input');
|
|
793
|
+
issuerTextInput.setAttribute('type', 'text');
|
|
794
|
+
issuerTextInput.setAttribute('style', 'margin-left: 0 !important; flex: 1; margin-right: 5px !important');
|
|
795
|
+
issuerTextInput.setAttribute('placeholder', 'https://example.com');
|
|
796
|
+
issuerTextInput.value = localStorage.getItem('loginIssuer') || '';
|
|
797
|
+
var issuerTextGoButton = dom.createElement('button');
|
|
798
|
+
issuerTextGoButton.innerText = 'Go';
|
|
799
|
+
issuerTextGoButton.setAttribute('style', 'margin-top: 12px; margin-bottom: 12px;');
|
|
800
|
+
issuerTextGoButton.addEventListener('click', function () {
|
|
801
|
+
loginToIssuer(issuerTextInput.value);
|
|
802
|
+
});
|
|
803
|
+
issuerTextContainer.appendChild(issuerTextLabel);
|
|
804
|
+
issuerTextInputContainer.appendChild(issuerTextInput);
|
|
805
|
+
issuerTextInputContainer.appendChild(issuerTextGoButton);
|
|
806
|
+
issuerTextContainer.appendChild(issuerTextInputContainer);
|
|
807
|
+
issuerPopupBox.appendChild(issuerTextContainer);
|
|
808
|
+
/**
|
|
809
|
+
* Button-based idp selection
|
|
810
|
+
*/
|
|
811
|
+
|
|
812
|
+
var issuerButtonContainer = dom.createElement('div');
|
|
813
|
+
issuerButtonContainer.setAttribute('style', "\n display: flex;\n flex-direction: column;\n padding-top: 10px;\n ");
|
|
814
|
+
var issuerBottonLabel = dom.createElement('label');
|
|
815
|
+
issuerBottonLabel.innerText = 'Or pick an identity provider from the list below:';
|
|
816
|
+
issuerBottonLabel.setAttribute('style', 'color: #888');
|
|
817
|
+
issuerButtonContainer.appendChild(issuerBottonLabel);
|
|
818
|
+
(0, _solidLogic.getSuggestedIssuers)().forEach(function (issuerInfo) {
|
|
819
|
+
var issuerButton = dom.createElement('button');
|
|
820
|
+
issuerButton.innerText = issuerInfo.name;
|
|
821
|
+
issuerButton.setAttribute('style', 'height: 38px; margin-top: 10px');
|
|
822
|
+
issuerButton.addEventListener('click', function () {
|
|
823
|
+
loginToIssuer(issuerInfo.uri);
|
|
824
|
+
});
|
|
825
|
+
issuerButtonContainer.appendChild(issuerButton);
|
|
826
|
+
});
|
|
827
|
+
issuerPopupBox.appendChild(issuerButtonContainer);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Login status box
|
|
831
|
+
*
|
|
832
|
+
* A big sign-up/sign in box or a logout box depending on the state
|
|
833
|
+
*
|
|
834
|
+
* @param dom
|
|
835
|
+
* @param listener
|
|
836
|
+
*
|
|
837
|
+
* @returns
|
|
838
|
+
*/
|
|
839
|
+
|
|
840
|
+
|
|
841
|
+
function loginStatusBox(dom) {
|
|
842
|
+
var listener = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
843
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
844
|
+
// 20190630
|
|
845
|
+
var me = (0, _solidLogic.offlineTestID)(); // @@ TODO Remove the need to cast HTML element to any
|
|
846
|
+
|
|
847
|
+
var box = dom.createElement('div');
|
|
848
|
+
|
|
849
|
+
function setIt(newidURI) {
|
|
850
|
+
if (!newidURI) {
|
|
851
|
+
return;
|
|
852
|
+
} // const uri = newidURI.uri || newidURI
|
|
853
|
+
// me = sym(uri)
|
|
854
|
+
|
|
855
|
+
|
|
856
|
+
me = _solidLogic.authn.saveUser(newidURI);
|
|
857
|
+
box.refresh();
|
|
858
|
+
if (listener) listener(me.uri);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function logoutButtonHandler(_event) {
|
|
862
|
+
var oldMe = me;
|
|
863
|
+
|
|
864
|
+
_solidLogic.authSession.logout().then(function () {
|
|
865
|
+
var message = "Your WebID was ".concat(oldMe, ". It has been forgotten.");
|
|
866
|
+
me = null;
|
|
867
|
+
|
|
868
|
+
try {
|
|
869
|
+
(0, _log.alert)(message);
|
|
870
|
+
} catch (e) {
|
|
871
|
+
window.alert(message);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
box.refresh();
|
|
875
|
+
if (listener) listener(null);
|
|
876
|
+
}, function (err) {
|
|
877
|
+
(0, _log.alert)('Fail to log out:' + err);
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function logoutButton(me, options) {
|
|
882
|
+
var signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle();
|
|
883
|
+
var logoutLabel = 'WebID logout';
|
|
884
|
+
|
|
885
|
+
if (me) {
|
|
886
|
+
var nick = _solidLogic.solidLogicSingleton.store.any(me, ns.foaf('nick')) || _solidLogic.solidLogicSingleton.store.any(me, ns.foaf('name'));
|
|
887
|
+
|
|
888
|
+
if (nick) {
|
|
889
|
+
logoutLabel = 'Logout ' + nick.value;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
var signOutButton = dom.createElement('input'); // signOutButton.className = 'WebIDCancelButton'
|
|
894
|
+
|
|
895
|
+
signOutButton.setAttribute('type', 'button');
|
|
896
|
+
signOutButton.setAttribute('value', logoutLabel);
|
|
897
|
+
signOutButton.setAttribute('style', "".concat(signInButtonStyle, "background-color: #eee;"));
|
|
898
|
+
signOutButton.addEventListener('click', logoutButtonHandler, false);
|
|
899
|
+
return signOutButton;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
box.refresh = function () {
|
|
903
|
+
me = _solidLogic.authn.currentUser();
|
|
904
|
+
|
|
905
|
+
if (me && box.me !== me.uri || !me && box.me) {
|
|
906
|
+
widgets.clearElement(box);
|
|
907
|
+
|
|
908
|
+
if (me) {
|
|
909
|
+
box.appendChild(logoutButton(me, options));
|
|
910
|
+
} else {
|
|
911
|
+
box.appendChild(signInOrSignUpBox(dom, setIt, options));
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
box.me = me ? me.uri : null;
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
box.refresh();
|
|
919
|
+
|
|
920
|
+
function trackSession() {
|
|
921
|
+
me = _solidLogic.authn.currentUser();
|
|
922
|
+
box.refresh();
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
trackSession();
|
|
926
|
+
|
|
927
|
+
_solidLogic.authSession.onLogin(trackSession);
|
|
928
|
+
|
|
929
|
+
_solidLogic.authSession.onLogout(trackSession);
|
|
930
|
+
|
|
931
|
+
box.me = '99999'; // Force refresh
|
|
932
|
+
|
|
933
|
+
box.refresh();
|
|
934
|
+
return box;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
_solidLogic.authSession.onLogout( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
938
|
+
var issuer, wellKnownUri, wellKnownResult, openidConfiguration;
|
|
939
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
940
|
+
while (1) {
|
|
941
|
+
switch (_context2.prev = _context2.next) {
|
|
942
|
+
case 0:
|
|
943
|
+
issuer = window.localStorage.getItem('loginIssuer');
|
|
944
|
+
|
|
945
|
+
if (!issuer) {
|
|
946
|
+
_context2.next = 19;
|
|
947
|
+
break;
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
_context2.prev = 2;
|
|
951
|
+
wellKnownUri = new URL(issuer);
|
|
952
|
+
wellKnownUri.pathname = '/.well-known/openid-configuration';
|
|
953
|
+
_context2.next = 7;
|
|
954
|
+
return fetch(wellKnownUri.toString());
|
|
955
|
+
|
|
956
|
+
case 7:
|
|
957
|
+
wellKnownResult = _context2.sent;
|
|
958
|
+
|
|
959
|
+
if (!(wellKnownResult.status === 200)) {
|
|
960
|
+
_context2.next = 15;
|
|
961
|
+
break;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
_context2.next = 11;
|
|
965
|
+
return wellKnownResult.json();
|
|
966
|
+
|
|
967
|
+
case 11:
|
|
968
|
+
openidConfiguration = _context2.sent;
|
|
969
|
+
|
|
970
|
+
if (!(openidConfiguration && openidConfiguration.end_session_endpoint)) {
|
|
971
|
+
_context2.next = 15;
|
|
972
|
+
break;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
_context2.next = 15;
|
|
976
|
+
return fetch(openidConfiguration.end_session_endpoint, {
|
|
977
|
+
credentials: 'include'
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
case 15:
|
|
981
|
+
_context2.next = 19;
|
|
982
|
+
break;
|
|
983
|
+
|
|
984
|
+
case 17:
|
|
985
|
+
_context2.prev = 17;
|
|
986
|
+
_context2.t0 = _context2["catch"](2);
|
|
987
|
+
|
|
988
|
+
case 19:
|
|
989
|
+
window.location.reload();
|
|
990
|
+
|
|
991
|
+
case 20:
|
|
992
|
+
case "end":
|
|
993
|
+
return _context2.stop();
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}, _callee2, null, [[2, 17]]);
|
|
997
|
+
})));
|
|
998
|
+
/**
|
|
999
|
+
* Workspace selection etc
|
|
1000
|
+
* See https://github.com/solid/userguide/issues/16
|
|
1001
|
+
*/
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Returns a UI object which, if it selects a workspace,
|
|
1005
|
+
* will callback(workspace, newBase).
|
|
1006
|
+
* See https://github.com/solid/userguide/issues/16 for more info on workspaces.
|
|
1007
|
+
*
|
|
1008
|
+
* If necessary, will get an account, preference file, etc. In sequence:
|
|
1009
|
+
*
|
|
1010
|
+
* - If not logged in, log in.
|
|
1011
|
+
* - Load preference file
|
|
1012
|
+
* - Prompt user for workspaces
|
|
1013
|
+
* - Allows the user to just type in a URI by hand
|
|
1014
|
+
*
|
|
1015
|
+
* Calls back with the workspace and the base URI
|
|
1016
|
+
*
|
|
1017
|
+
* @param dom
|
|
1018
|
+
* @param appDetails
|
|
1019
|
+
* @param callbackWS
|
|
1020
|
+
*/
|
|
1021
|
+
|
|
1022
|
+
|
|
1023
|
+
function selectWorkspace(dom, appDetails, callbackWS) {
|
|
1024
|
+
var noun = appDetails.noun;
|
|
1025
|
+
var appPathSegment = appDetails.appPathSegment;
|
|
1026
|
+
var me = (0, _solidLogic.offlineTestID)();
|
|
1027
|
+
var box = dom.createElement('div');
|
|
1028
|
+
var context = {
|
|
1029
|
+
me: me,
|
|
1030
|
+
dom: dom,
|
|
1031
|
+
div: box
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
function say(s, background) {
|
|
1035
|
+
box.appendChild(widgets.errorMessageBlock(dom, s, background));
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
function figureOutBase(ws) {
|
|
1039
|
+
var newBaseNode = _solidLogic.solidLogicSingleton.store.any(ws, ns.space('uriPrefix'));
|
|
1040
|
+
|
|
1041
|
+
var newBaseString;
|
|
1042
|
+
|
|
1043
|
+
if (!newBaseNode) {
|
|
1044
|
+
newBaseString = ws.uri.split('#')[0];
|
|
1045
|
+
} else {
|
|
1046
|
+
newBaseString = newBaseNode.value;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
if (newBaseString.slice(-1) !== '/') {
|
|
1050
|
+
debug.log("".concat(appPathSegment, ": No / at end of uriPrefix ").concat(newBaseString)); // @@ paramater?
|
|
1051
|
+
|
|
1052
|
+
newBaseString = "".concat(newBaseString, "/");
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
var now = new Date();
|
|
1056
|
+
newBaseString += "".concat(appPathSegment, "/id").concat(now.getTime(), "/"); // unique id
|
|
1057
|
+
|
|
1058
|
+
return newBaseString;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
function displayOptions(context) {
|
|
1062
|
+
// console.log('displayOptions!', context)
|
|
1063
|
+
function makeNewWorkspace(_x8) {
|
|
1064
|
+
return _makeNewWorkspace.apply(this, arguments);
|
|
1065
|
+
} // const status = ''
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
function _makeNewWorkspace() {
|
|
1069
|
+
_makeNewWorkspace = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(_event) {
|
|
1070
|
+
var row, cell, newBase, newWs, newData;
|
|
1071
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
1072
|
+
while (1) {
|
|
1073
|
+
switch (_context3.prev = _context3.next) {
|
|
1074
|
+
case 0:
|
|
1075
|
+
row = table.appendChild(dom.createElement('tr'));
|
|
1076
|
+
cell = row.appendChild(dom.createElement('td'));
|
|
1077
|
+
cell.setAttribute('colspan', '3');
|
|
1078
|
+
cell.style.padding = '0.5em';
|
|
1079
|
+
_context3.t0 = encodeURI;
|
|
1080
|
+
_context3.next = 7;
|
|
1081
|
+
return widgets.askName(dom, _solidLogic.solidLogicSingleton.store, cell, ns.solid('URL'), ns.space('Workspace'), 'Workspace');
|
|
1082
|
+
|
|
1083
|
+
case 7:
|
|
1084
|
+
_context3.t1 = _context3.sent;
|
|
1085
|
+
newBase = (0, _context3.t0)(_context3.t1);
|
|
1086
|
+
newWs = widgets.newThing(context.preferencesFile);
|
|
1087
|
+
newData = [(0, _rdflib.st)(context.me, ns.space('workspace'), newWs, context.preferencesFile), // eslint-disable-next-line camelcase
|
|
1088
|
+
(0, _rdflib.st)(newWs, ns.space('uriPrefix'), newBase, context.preferencesFile)];
|
|
1089
|
+
|
|
1090
|
+
if (_solidLogic.solidLogicSingleton.store.updater) {
|
|
1091
|
+
_context3.next = 13;
|
|
1092
|
+
break;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
throw new Error('store has no updater');
|
|
1096
|
+
|
|
1097
|
+
case 13:
|
|
1098
|
+
_context3.next = 15;
|
|
1099
|
+
return _solidLogic.solidLogicSingleton.store.updater.update([], newData);
|
|
1100
|
+
|
|
1101
|
+
case 15:
|
|
1102
|
+
case "end":
|
|
1103
|
+
return _context3.stop();
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}, _callee3);
|
|
1107
|
+
}));
|
|
1108
|
+
return _makeNewWorkspace.apply(this, arguments);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
var id = context.me;
|
|
1112
|
+
var preferencesFile = context.preferencesFile;
|
|
1113
|
+
var newBase = null; // A workspace specifically defined in the private preference file:
|
|
1114
|
+
|
|
1115
|
+
var w = _solidLogic.solidLogicSingleton.store.each(id, ns.space('workspace'), undefined, preferencesFile); // Only trust preference file here
|
|
1116
|
+
// A workspace in a storage in the public profile:
|
|
1117
|
+
|
|
1118
|
+
|
|
1119
|
+
var storages = _solidLogic.solidLogicSingleton.store.each(id, ns.space('storage')); // @@ No provenance requirement at the moment
|
|
1120
|
+
|
|
1121
|
+
|
|
1122
|
+
if (w.length === 0 && storages) {
|
|
1123
|
+
say("You don't seem to have any workspaces. You have ".concat(storages.length, " storage spaces."), 'white');
|
|
1124
|
+
storages.map(function (s) {
|
|
1125
|
+
w = w.concat(_solidLogic.solidLogicSingleton.store.each(s, ns.ldp('contains')));
|
|
1126
|
+
return w;
|
|
1127
|
+
}).filter(function (file) {
|
|
1128
|
+
return file.id ? ['public', 'private'].includes(file.id().toLowerCase()) : '';
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
if (w.length === 1) {
|
|
1133
|
+
say("Workspace used: ".concat(w[0].uri), 'white'); // @@ allow user to see URI
|
|
1134
|
+
|
|
1135
|
+
newBase = figureOutBase(w[0]); // callbackWS(w[0], newBase)
|
|
1136
|
+
// } else if (w.length === 0) {
|
|
1137
|
+
} // Prompt for ws selection or creation
|
|
1138
|
+
// say( w.length + " workspaces for " + id + "Choose one.");
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
var table = dom.createElement('table');
|
|
1142
|
+
table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;'); // const popup = window.open(undefined, '_blank', { height: 300, width:400 }, false)
|
|
1143
|
+
|
|
1144
|
+
box.appendChild(table); // Add a field for directly adding the URI yourself
|
|
1145
|
+
// const hr = box.appendChild(dom.createElement('hr')) // @@
|
|
1146
|
+
|
|
1147
|
+
box.appendChild(dom.createElement('hr')); // @@
|
|
1148
|
+
|
|
1149
|
+
var p = box.appendChild(dom.createElement('p'));
|
|
1150
|
+
p.style = _style.commentStyle;
|
|
1151
|
+
p.textContent = "Where would you like to store the data for the ".concat(noun, "?\n Give the URL of the folder where you would like the data stored.\n It can be anywhere in solid world - this URI is just an idea."); // @@ TODO Remove the need to cast baseField to any
|
|
1152
|
+
|
|
1153
|
+
var baseField = box.appendChild(dom.createElement('input'));
|
|
1154
|
+
baseField.setAttribute('type', 'text');
|
|
1155
|
+
baseField.style = _style.textInputStyle;
|
|
1156
|
+
baseField.size = 80; // really a string
|
|
1157
|
+
|
|
1158
|
+
baseField.label = 'base URL';
|
|
1159
|
+
baseField.autocomplete = 'on';
|
|
1160
|
+
|
|
1161
|
+
if (newBase) {
|
|
1162
|
+
// set to default
|
|
1163
|
+
baseField.value = newBase;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
context.baseField = baseField;
|
|
1167
|
+
box.appendChild(dom.createElement('br')); // @@
|
|
1168
|
+
|
|
1169
|
+
var button = box.appendChild(dom.createElement('button'));
|
|
1170
|
+
button.style = _style.buttonStyle;
|
|
1171
|
+
button.textContent = "Start new ".concat(noun, " at this URI");
|
|
1172
|
+
button.addEventListener('click', function (_event) {
|
|
1173
|
+
var newBase = baseField.value.replace(' ', '%20'); // do not re-encode in general, as % encodings may exist
|
|
1174
|
+
|
|
1175
|
+
if (newBase.slice(-1) !== '/') {
|
|
1176
|
+
newBase += '/';
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
callbackWS(null, newBase);
|
|
1180
|
+
}); // Now go set up the table of spaces
|
|
1181
|
+
// const row = 0
|
|
1182
|
+
|
|
1183
|
+
w = w.filter(function (x) {
|
|
1184
|
+
return !_solidLogic.solidLogicSingleton.store.holds(x, ns.rdf('type'), // Ignore master workspaces
|
|
1185
|
+
ns.space('MasterWorkspace'));
|
|
1186
|
+
});
|
|
1187
|
+
var col1, col2, col3, tr, ws, style, comment;
|
|
1188
|
+
var cellStyle = 'height: 3em; margin: 1em; padding: 1em white; border-radius: 0.3em;';
|
|
1189
|
+
var deselectedStyle = "".concat(cellStyle, "border: 0px;"); // const selectedStyle = cellStyle + 'border: 1px solid black;'
|
|
1190
|
+
|
|
1191
|
+
for (var i = 0; i < w.length; i++) {
|
|
1192
|
+
ws = w[i];
|
|
1193
|
+
tr = dom.createElement('tr');
|
|
1194
|
+
|
|
1195
|
+
if (i === 0) {
|
|
1196
|
+
col1 = dom.createElement('td');
|
|
1197
|
+
col1.setAttribute('rowspan', "".concat(w.length));
|
|
1198
|
+
col1.textContent = 'Choose a workspace for this:';
|
|
1199
|
+
col1.setAttribute('style', 'vertical-align:middle;');
|
|
1200
|
+
tr.appendChild(col1);
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
col2 = dom.createElement('td');
|
|
1204
|
+
style = _solidLogic.solidLogicSingleton.store.anyValue(ws, ns.ui('style'));
|
|
1205
|
+
|
|
1206
|
+
if (!style) {
|
|
1207
|
+
// Otherwise make up arbitrary colour
|
|
1208
|
+
var hash = function hash(x) {
|
|
1209
|
+
return x.split('').reduce(function (a, b) {
|
|
1210
|
+
a = (a << 5) - a + b.charCodeAt(0);
|
|
1211
|
+
return a & a;
|
|
1212
|
+
}, 0);
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
var bgcolor = "#".concat((hash(ws.uri) & 0xffffff | 0xc0c0c0).toString(16)); // c0c0c0 forces pale
|
|
1216
|
+
|
|
1217
|
+
style = "color: black ; background-color: ".concat(bgcolor, ";");
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
col2.setAttribute('style', deselectedStyle + style);
|
|
1221
|
+
tr.target = ws.uri;
|
|
1222
|
+
|
|
1223
|
+
var label = _solidLogic.solidLogicSingleton.store.any(ws, ns.rdfs('label'));
|
|
1224
|
+
|
|
1225
|
+
if (!label) {
|
|
1226
|
+
label = ws.uri.split('/').slice(-1)[0] || ws.uri.split('/').slice(-2)[0];
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
col2.textContent = label || '???';
|
|
1230
|
+
tr.appendChild(col2);
|
|
1231
|
+
|
|
1232
|
+
if (i === 0) {
|
|
1233
|
+
col3 = dom.createElement('td');
|
|
1234
|
+
col3.setAttribute('rowspan', "".concat(w.length, "1")); // col3.textContent = '@@@@@ remove';
|
|
1235
|
+
|
|
1236
|
+
col3.setAttribute('style', 'width:50%;');
|
|
1237
|
+
tr.appendChild(col3);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
table.appendChild(tr);
|
|
1241
|
+
comment = _solidLogic.solidLogicSingleton.store.any(ws, ns.rdfs('comment'));
|
|
1242
|
+
comment = comment ? comment.value : 'Use this workspace';
|
|
1243
|
+
col2.addEventListener('click', function (_event) {
|
|
1244
|
+
col3.textContent = comment ? comment.value : '';
|
|
1245
|
+
col3.setAttribute('style', deselectedStyle + style);
|
|
1246
|
+
var button = dom.createElement('button');
|
|
1247
|
+
button.textContent = 'Continue'; // button.setAttribute('style', style);
|
|
1248
|
+
|
|
1249
|
+
var newBase = figureOutBase(ws);
|
|
1250
|
+
baseField.value = newBase; // show user proposed URI
|
|
1251
|
+
|
|
1252
|
+
button.addEventListener('click', function (_event) {
|
|
1253
|
+
button.disabled = true;
|
|
1254
|
+
callbackWS(ws, newBase);
|
|
1255
|
+
button.textContent = '---->';
|
|
1256
|
+
}, true); // capture vs bubble
|
|
1257
|
+
|
|
1258
|
+
col3.appendChild(button);
|
|
1259
|
+
}, true); // capture vs bubble
|
|
1260
|
+
} // last line with "Make new workspace"
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
var trLast = dom.createElement('tr');
|
|
1264
|
+
col2 = dom.createElement('td');
|
|
1265
|
+
col2.setAttribute('style', cellStyle);
|
|
1266
|
+
col2.textContent = '+ Make a new workspace';
|
|
1267
|
+
col2.addEventListener('click', makeNewWorkspace);
|
|
1268
|
+
trLast.appendChild(col2);
|
|
1269
|
+
table.appendChild(trLast);
|
|
1270
|
+
} // displayOptions
|
|
1271
|
+
// console.log('kicking off async operation')
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
ensureLoadedPreferences(context) // kick off async operation
|
|
1275
|
+
.then(displayOptions)["catch"](function (err) {
|
|
1276
|
+
// console.log("err from async op")
|
|
1277
|
+
box.appendChild(widgets.errorMessageBlock(context.dom, err));
|
|
1278
|
+
});
|
|
1279
|
+
return box; // return the box element, while login proceeds
|
|
1280
|
+
} // selectWorkspace
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* Creates a new instance of an app.
|
|
1284
|
+
*
|
|
1285
|
+
* An instance of an app could be e.g. an issue tracker for a given project,
|
|
1286
|
+
* or a chess game, or calendar, or a health/fitness record for a person.
|
|
1287
|
+
*
|
|
1288
|
+
* Note that this use of the term 'app' refers more to entries in the user's
|
|
1289
|
+
* type index than to actual software applications that use the personal data
|
|
1290
|
+
* to which these entries point.
|
|
1291
|
+
*
|
|
1292
|
+
* @param dom
|
|
1293
|
+
* @param appDetails
|
|
1294
|
+
* @param callback
|
|
1295
|
+
*
|
|
1296
|
+
* @returns A div with a button in it for making a new app instance
|
|
1297
|
+
*/
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
function newAppInstance(dom, appDetails, callback) {
|
|
1301
|
+
var gotWS = function gotWS(ws, base) {
|
|
1302
|
+
// log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none'))
|
|
1303
|
+
callback(ws, base);
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
var div = dom.createElement('div');
|
|
1307
|
+
var b = dom.createElement('button');
|
|
1308
|
+
b.setAttribute('type', 'button');
|
|
1309
|
+
div.appendChild(b);
|
|
1310
|
+
b.innerHTML = "Make new ".concat(appDetails.noun);
|
|
1311
|
+
b.addEventListener('click', function (_event) {
|
|
1312
|
+
div.appendChild(selectWorkspace(dom, appDetails, gotWS));
|
|
1313
|
+
}, false);
|
|
1314
|
+
div.appendChild(b);
|
|
1315
|
+
return div;
|
|
1316
|
+
}
|
|
1317
|
+
/**
|
|
1318
|
+
* Retrieves whether the currently logged in user is a power user
|
|
1319
|
+
* and/or a developer
|
|
1320
|
+
*/
|
|
1321
|
+
|
|
1322
|
+
|
|
1323
|
+
function getUserRoles() {
|
|
1324
|
+
return _getUserRoles.apply(this, arguments);
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* Filters which panes should be available, based on the result of [[getUserRoles]]
|
|
1328
|
+
*/
|
|
1329
|
+
|
|
1330
|
+
|
|
1331
|
+
function _getUserRoles() {
|
|
1332
|
+
_getUserRoles = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
|
|
1333
|
+
var _yield$ensureLoadedPr, me, preferencesFile, preferencesFileError;
|
|
1334
|
+
|
|
1335
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
1336
|
+
while (1) {
|
|
1337
|
+
switch (_context7.prev = _context7.next) {
|
|
1338
|
+
case 0:
|
|
1339
|
+
_context7.prev = 0;
|
|
1340
|
+
_context7.next = 3;
|
|
1341
|
+
return ensureLoadedPreferences({});
|
|
1342
|
+
|
|
1343
|
+
case 3:
|
|
1344
|
+
_yield$ensureLoadedPr = _context7.sent;
|
|
1345
|
+
me = _yield$ensureLoadedPr.me;
|
|
1346
|
+
preferencesFile = _yield$ensureLoadedPr.preferencesFile;
|
|
1347
|
+
preferencesFileError = _yield$ensureLoadedPr.preferencesFileError;
|
|
1348
|
+
|
|
1349
|
+
if (!(!preferencesFile || preferencesFileError)) {
|
|
1350
|
+
_context7.next = 9;
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
|
|
1354
|
+
throw new Error(preferencesFileError);
|
|
1355
|
+
|
|
1356
|
+
case 9:
|
|
1357
|
+
return _context7.abrupt("return", _solidLogic.solidLogicSingleton.store.each(me, ns.rdf('type'), null, preferencesFile.doc()));
|
|
1358
|
+
|
|
1359
|
+
case 12:
|
|
1360
|
+
_context7.prev = 12;
|
|
1361
|
+
_context7.t0 = _context7["catch"](0);
|
|
1362
|
+
debug.warn('Unable to fetch your preferences - this was the error: ', _context7.t0);
|
|
1363
|
+
|
|
1364
|
+
case 15:
|
|
1365
|
+
return _context7.abrupt("return", []);
|
|
1366
|
+
|
|
1367
|
+
case 16:
|
|
1368
|
+
case "end":
|
|
1369
|
+
return _context7.stop();
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}, _callee7, null, [[0, 12]]);
|
|
1373
|
+
}));
|
|
1374
|
+
return _getUserRoles.apply(this, arguments);
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
function filterAvailablePanes(_x9) {
|
|
1378
|
+
return _filterAvailablePanes.apply(this, arguments);
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
function _filterAvailablePanes() {
|
|
1382
|
+
_filterAvailablePanes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(panes) {
|
|
1383
|
+
var userRoles;
|
|
1384
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
1385
|
+
while (1) {
|
|
1386
|
+
switch (_context8.prev = _context8.next) {
|
|
1387
|
+
case 0:
|
|
1388
|
+
_context8.next = 2;
|
|
1389
|
+
return getUserRoles();
|
|
1390
|
+
|
|
1391
|
+
case 2:
|
|
1392
|
+
userRoles = _context8.sent;
|
|
1393
|
+
return _context8.abrupt("return", panes.filter(function (pane) {
|
|
1394
|
+
return isMatchingAudience(pane, userRoles);
|
|
1395
|
+
}));
|
|
1396
|
+
|
|
1397
|
+
case 4:
|
|
1398
|
+
case "end":
|
|
1399
|
+
return _context8.stop();
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
}, _callee8);
|
|
1403
|
+
}));
|
|
1404
|
+
return _filterAvailablePanes.apply(this, arguments);
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
function isMatchingAudience(pane, userRoles) {
|
|
1408
|
+
var audience = pane.audience || [];
|
|
1409
|
+
return audience.reduce(function (isMatch, audienceRole) {
|
|
1410
|
+
return isMatch && !!userRoles.find(function (role) {
|
|
1411
|
+
return role.equals(audienceRole);
|
|
1412
|
+
});
|
|
1413
|
+
}, true);
|
|
1414
|
+
}
|
|
1415
|
+
//# sourceMappingURL=login.js.map
|