@nr-connect/node-red 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +151 -3
- package/examples/starter-demo.json +776 -0
- package/index.html +1939 -0
- package/index.js +76 -0
- package/lib/binaryManager.js +557 -0
- package/lib/connectionManager.js +1060 -0
- package/lib/connectorManifest.json +61 -0
- package/lib/dashboardRbac.js +670 -0
- package/lib/expressInterceptor.js +917 -0
- package/lib/pageSyncAgent.js +149 -0
- package/lib/pushAgent.js +253 -0
- package/lib/qrCode.js +625 -0
- package/lib/statusEndpoint.js +231 -0
- package/lib/tokenCodec.js +98 -0
- package/lib/tunnelDaemon.js +236 -0
- package/nodes/nr-connect-notify.html +258 -0
- package/nodes/nr-connect-notify.js +303 -0
- package/nodes/ui-nr-connect-profile.html +211 -0
- package/nodes/ui-nr-connect-profile.js +66 -0
- package/package.json +80 -6
- package/resources/ui-nr-connect-profile.umd.js +213 -0
- package/ui/UINrConnectProfile.js +1173 -0
- package/ui/profile.js +1 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
(function () {
|
|
3
|
+
var categoryKey = "@flowfuse/node-red-dashboard/ui-base:ui-base.label.category";
|
|
4
|
+
var translatedCategory = typeof RED._ === "function" ? RED._(categoryKey) : "";
|
|
5
|
+
var widgetCategory =
|
|
6
|
+
translatedCategory &&
|
|
7
|
+
translatedCategory !== categoryKey &&
|
|
8
|
+
translatedCategory !== "ui-base.label.category"
|
|
9
|
+
? translatedCategory
|
|
10
|
+
: "dashboard 2";
|
|
11
|
+
|
|
12
|
+
RED.nodes.registerType("ui-nr-connect-profile", {
|
|
13
|
+
category: widgetCategory,
|
|
14
|
+
color: "#e6625d",
|
|
15
|
+
defaults: {
|
|
16
|
+
name: { value: "" },
|
|
17
|
+
placement: { value: "group" },
|
|
18
|
+
group: {
|
|
19
|
+
type: "ui-group",
|
|
20
|
+
required: false,
|
|
21
|
+
validate: function () {
|
|
22
|
+
var p = $("#node-input-placement").val() || this.placement || "group";
|
|
23
|
+
var g =
|
|
24
|
+
$("#node-input-group").val() !== undefined
|
|
25
|
+
? $("#node-input-group").val()
|
|
26
|
+
: this.group;
|
|
27
|
+
return p !== "group" || (!!g && g !== "_ADD_");
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
ui: {
|
|
31
|
+
type: "ui-base",
|
|
32
|
+
required: false,
|
|
33
|
+
validate: function () {
|
|
34
|
+
var p = $("#node-input-placement").val() || this.placement || "group";
|
|
35
|
+
var u =
|
|
36
|
+
$("#node-input-ui").val() !== undefined
|
|
37
|
+
? $("#node-input-ui").val()
|
|
38
|
+
: this.ui;
|
|
39
|
+
return p !== "appbar" || (!!u && u !== "_ADD_");
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
order: { value: 0 },
|
|
43
|
+
width: {
|
|
44
|
+
value: 0,
|
|
45
|
+
validate: function (v) {
|
|
46
|
+
var p = $("#node-input-placement").val() || this.placement || "group";
|
|
47
|
+
if (p === "appbar") {
|
|
48
|
+
$("#node-input-size").toggleClass("input-error", false);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
var width = v || 0;
|
|
52
|
+
var currentGroup = $("#node-input-group").val() || this.group;
|
|
53
|
+
var groupNode = RED.nodes.node(currentGroup);
|
|
54
|
+
var valid = !groupNode || +width <= +groupNode.width;
|
|
55
|
+
$("#node-input-size").toggleClass("input-error", !valid);
|
|
56
|
+
return valid;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
height: { value: 0 },
|
|
60
|
+
showEmail: { value: true },
|
|
61
|
+
showRole: { value: true },
|
|
62
|
+
showSignOut: { value: true },
|
|
63
|
+
showPushToggle: { value: true },
|
|
64
|
+
pushLabel: { value: "Push Notifications" },
|
|
65
|
+
showPushStatus: { value: true },
|
|
66
|
+
autoSyncPush: { value: true },
|
|
67
|
+
},
|
|
68
|
+
inputs: 0,
|
|
69
|
+
outputs: 1,
|
|
70
|
+
icon: "font-awesome/fa-user-circle",
|
|
71
|
+
paletteLabel: "nrc profile",
|
|
72
|
+
label: function () {
|
|
73
|
+
return this.name || "nrc profile";
|
|
74
|
+
},
|
|
75
|
+
labelStyle: function () {
|
|
76
|
+
return this.name ? "node_label_italic" : "";
|
|
77
|
+
},
|
|
78
|
+
oneditprepare: function () {
|
|
79
|
+
var $placement = $("#node-input-placement");
|
|
80
|
+
if (!$placement.val()) {
|
|
81
|
+
$placement.val(this.placement || "group");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var $size = $("#node-input-size");
|
|
85
|
+
var sizerOpts = {
|
|
86
|
+
width: "#node-input-width",
|
|
87
|
+
height: "#node-input-height",
|
|
88
|
+
group: "#node-input-group",
|
|
89
|
+
};
|
|
90
|
+
if (typeof $size.ffElementSizer === "function") {
|
|
91
|
+
$size.ffElementSizer(sizerOpts);
|
|
92
|
+
} else if (typeof $size.elementSizer === "function") {
|
|
93
|
+
$size.elementSizer(sizerOpts);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function updatePlacementRows() {
|
|
97
|
+
var isAppBar = $placement.val() === "appbar";
|
|
98
|
+
$(".nrc-row-group").toggle(!isAppBar);
|
|
99
|
+
$(".nrc-row-ui").toggle(isAppBar);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function updatePushRows() {
|
|
103
|
+
var showPush = Boolean($("#node-input-showPushToggle").prop("checked"));
|
|
104
|
+
$(".nrc-row-push").toggle(showPush);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
$placement.on("change", updatePlacementRows);
|
|
108
|
+
$placement.trigger("change");
|
|
109
|
+
|
|
110
|
+
$("#node-input-showPushToggle").on("change", updatePushRows);
|
|
111
|
+
updatePushRows();
|
|
112
|
+
},
|
|
113
|
+
oneditsave: function () {
|
|
114
|
+
if ($("#node-input-placement").val() === "appbar") {
|
|
115
|
+
$("#node-input-group").val("");
|
|
116
|
+
this.group = "";
|
|
117
|
+
} else {
|
|
118
|
+
$("#node-input-ui").val("");
|
|
119
|
+
this.ui = "";
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
})();
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<script type="text/html" data-template-name="ui-nr-connect-profile">
|
|
127
|
+
<div class="form-row">
|
|
128
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
129
|
+
<input type="text" id="node-input-name" placeholder="Name" />
|
|
130
|
+
</div>
|
|
131
|
+
<div class="form-row">
|
|
132
|
+
<label for="node-input-placement"><i class="fa fa-map-pin"></i> Placement</label>
|
|
133
|
+
<select id="node-input-placement">
|
|
134
|
+
<option value="group">In group</option>
|
|
135
|
+
<option value="appbar">App bar (top-right)</option>
|
|
136
|
+
</select>
|
|
137
|
+
</div>
|
|
138
|
+
<div class="form-row nrc-row-group">
|
|
139
|
+
<label for="node-input-group"><i class="fa fa-table"></i> Group</label>
|
|
140
|
+
<input type="text" id="node-input-group" />
|
|
141
|
+
</div>
|
|
142
|
+
<div class="form-row nrc-row-ui">
|
|
143
|
+
<label for="node-input-ui"><i class="fa fa-desktop"></i> UI</label>
|
|
144
|
+
<input type="text" id="node-input-ui" />
|
|
145
|
+
</div>
|
|
146
|
+
<div class="form-row nrc-row-group">
|
|
147
|
+
<label><i class="fa fa-object-group"></i> Size</label>
|
|
148
|
+
<input type="hidden" id="node-input-width" />
|
|
149
|
+
<input type="hidden" id="node-input-height" />
|
|
150
|
+
<button class="editor-button" id="node-input-size"></button>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="form-row">
|
|
153
|
+
<label> </label>
|
|
154
|
+
<input type="checkbox" id="node-input-showEmail" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
155
|
+
<label for="node-input-showEmail" style="width:70%;">Show email</label>
|
|
156
|
+
</div>
|
|
157
|
+
<div class="form-row">
|
|
158
|
+
<label> </label>
|
|
159
|
+
<input type="checkbox" id="node-input-showRole" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
160
|
+
<label for="node-input-showRole" style="width:70%;">Show role</label>
|
|
161
|
+
</div>
|
|
162
|
+
<div class="form-row">
|
|
163
|
+
<label> </label>
|
|
164
|
+
<input type="checkbox" id="node-input-showSignOut" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
165
|
+
<label for="node-input-showSignOut" style="width:70%;">Show sign-out button</label>
|
|
166
|
+
</div>
|
|
167
|
+
<div class="form-row">
|
|
168
|
+
<label> </label>
|
|
169
|
+
<input type="checkbox" id="node-input-showPushToggle" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
170
|
+
<label for="node-input-showPushToggle" style="width:70%;">Include push notifications switch</label>
|
|
171
|
+
</div>
|
|
172
|
+
<div class="form-row nrc-row-push">
|
|
173
|
+
<label for="node-input-pushLabel"><i class="fa fa-bell-o"></i> Push label</label>
|
|
174
|
+
<input type="text" id="node-input-pushLabel" placeholder="Push Notifications" />
|
|
175
|
+
</div>
|
|
176
|
+
<div class="form-row nrc-row-push">
|
|
177
|
+
<label> </label>
|
|
178
|
+
<input type="checkbox" id="node-input-showPushStatus" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
179
|
+
<label for="node-input-showPushStatus" style="width:70%;">Show push status helper text</label>
|
|
180
|
+
</div>
|
|
181
|
+
<div class="form-row nrc-row-push">
|
|
182
|
+
<label> </label>
|
|
183
|
+
<input type="checkbox" id="node-input-autoSyncPush" style="display:inline-block; width:auto; vertical-align:top;" />
|
|
184
|
+
<label for="node-input-autoSyncPush" style="width:70%;">Automatically sync existing browser push subscription</label>
|
|
185
|
+
</div>
|
|
186
|
+
</script>
|
|
187
|
+
|
|
188
|
+
<script type="text/html" data-help-name="ui-nr-connect-profile">
|
|
189
|
+
<p>Dashboard 2.0 widget displaying the currently signed-in NR Connect user profile, browser push notification toggle, and sign-out action.</p>
|
|
190
|
+
<h3>Placements</h3>
|
|
191
|
+
<ul>
|
|
192
|
+
<li><b>In group</b>: Renders a compact profile card inside the selected Dashboard 2.0 group.</li>
|
|
193
|
+
<li><b>App bar (top-right)</b>: Renders an avatar button in the Dashboard 2.0 top bar that opens a profile menu on every page. Requires the dashboard title bar to be visible (not hidden).</li>
|
|
194
|
+
</ul>
|
|
195
|
+
<h3>Settings</h3>
|
|
196
|
+
<ul>
|
|
197
|
+
<li><b>Show email / Show role / Show sign-out button</b>: Toggle individual profile details and actions.</li>
|
|
198
|
+
<li><b>Include push notifications switch</b>: Shows or hides the push opt-in toggle, along with its custom <b>Push label</b> and <b>Show push status helper text</b>.</li>
|
|
199
|
+
<li><b>Automatically sync existing browser push subscription</b>: When enabled, browsers that already granted notification permission silently re-sync their push token with NR Connect when the dashboard loads.</li>
|
|
200
|
+
</ul>
|
|
201
|
+
<h3>Push Notifications</h3>
|
|
202
|
+
<p>When signed in via NR Connect and push is enabled on the portal, users can toggle OS browser push notifications directly from this widget. Signing out automatically unregisters the current browser's push subscription.</p>
|
|
203
|
+
<p>When accessed locally without NR Connect edge authentication, the widget displays a neutral "Local access" state without push controls or a sign-out button.</p>
|
|
204
|
+
<h3>Outputs</h3>
|
|
205
|
+
<dl class="message-properties">
|
|
206
|
+
<dt>topic <span class="property-type">string</span></dt>
|
|
207
|
+
<dd><code>"push"</code> when a foreground push message arrives, or <code>"push_subscribed"</code> / <code>"push_unsubscribed"</code> on toggle.</dd>
|
|
208
|
+
<dt>payload <span class="property-type">object</span></dt>
|
|
209
|
+
<dd>Notification payload or subscription status details (<code>{ subscribed }</code>).</dd>
|
|
210
|
+
</dl>
|
|
211
|
+
</script>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const WIDGET_SRC = {
|
|
6
|
+
package: "@nr-connect/node-red",
|
|
7
|
+
name: "ui-nr-connect-profile",
|
|
8
|
+
src: "ui-nr-connect-profile.umd.js",
|
|
9
|
+
path: path.resolve(__dirname, ".."),
|
|
10
|
+
component: "UINrConnectProfile",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
module.exports = function (RED) {
|
|
14
|
+
function UINrConnectProfileNode(config) {
|
|
15
|
+
RED.nodes.createNode(this, config);
|
|
16
|
+
const node = this;
|
|
17
|
+
const placement = config.placement === "appbar" ? "appbar" : "group";
|
|
18
|
+
const evts = {
|
|
19
|
+
onAction: true,
|
|
20
|
+
};
|
|
21
|
+
let base = null;
|
|
22
|
+
|
|
23
|
+
// Preserve client-emitted msg.topic ("push", "push_subscribed", "push_unsubscribed")
|
|
24
|
+
// when Dashboard 2.0's onAction pipeline runs appendTopic().
|
|
25
|
+
const baseConfig = {
|
|
26
|
+
...config,
|
|
27
|
+
placement,
|
|
28
|
+
topic: config.topic || "topic",
|
|
29
|
+
topicType: config.topicType || "msg",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
if (placement === "appbar") {
|
|
33
|
+
base = RED.nodes.getNode(config.ui);
|
|
34
|
+
if (!base) {
|
|
35
|
+
node.error("No Dashboard 2.0 ui-base configured for app bar placement");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Dashboard 2.0 renders UI-scoped widgets only when props.group and props.page are falsy.
|
|
39
|
+
base.register(null, null, node, { ...baseConfig, group: "", page: "" }, evts);
|
|
40
|
+
} else {
|
|
41
|
+
const group = RED.nodes.getNode(config.group);
|
|
42
|
+
if (!group) {
|
|
43
|
+
node.error("No Dashboard 2.0 group configured");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
group.register(node, { ...baseConfig, ui: "" }, evts);
|
|
47
|
+
base = group.getBase();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Ensure Dashboard 2.0 attaches external UMD metadata even when @nr-connect/node-red
|
|
51
|
+
// is hoisted in npm workspaces or does not match the 'node-red-dashboard-2-' prefix filter.
|
|
52
|
+
const registered = base?.ui?.widgets?.get?.(node.id);
|
|
53
|
+
if (registered && !registered.src) {
|
|
54
|
+
registered.src = { ...WIDGET_SRC };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
node.on("close", (_removed, done) => {
|
|
58
|
+
if (placement === "appbar") {
|
|
59
|
+
base?.deregister?.(null, null, node);
|
|
60
|
+
}
|
|
61
|
+
done();
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
RED.nodes.registerType("ui-nr-connect-profile", UINrConnectProfileNode);
|
|
66
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nr-connect/node-red",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@nr-connect/node-red",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Zero-config remote access, FlowFuse Dashboard 2.0 multi-user authentication & page-level RBAC, public webhooks, and push notifications for Node-RED",
|
|
5
|
+
"homepage": "https://nr-connect.com/docs",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/nr-connect/community/issues",
|
|
8
|
+
"email": "support@nr-connect.com"
|
|
9
|
+
},
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"examples/",
|
|
13
|
+
"index.js",
|
|
14
|
+
"index.html",
|
|
15
|
+
"lib/",
|
|
16
|
+
"nodes/",
|
|
17
|
+
"resources/",
|
|
18
|
+
"ui/"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build:ui": "vite build",
|
|
22
|
+
"test:node": "node --test test/plugin.test.js test/nodes.test.js test/lib-edge-cases.test.js test/status-and-sync.test.js test/runtime-smoke.test.js test/runtime-e2e.test.js",
|
|
23
|
+
"test:ui": "vitest run",
|
|
24
|
+
"test": "npm run test:node && npm run test:ui",
|
|
25
|
+
"prepublishOnly": "npm run build:ui && npm test"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"node-red-plugin",
|
|
32
|
+
"nr-connect",
|
|
33
|
+
"remote-access",
|
|
34
|
+
"dashboard-2",
|
|
35
|
+
"node-red-dashboard-2",
|
|
36
|
+
"@flowfuse/node-red-dashboard",
|
|
37
|
+
"flowfuse",
|
|
38
|
+
"dashboard",
|
|
39
|
+
"authentication",
|
|
40
|
+
"auth",
|
|
41
|
+
"rbac",
|
|
42
|
+
"multi-user",
|
|
43
|
+
"permissions",
|
|
44
|
+
"security",
|
|
45
|
+
"webhook",
|
|
46
|
+
"notifications",
|
|
47
|
+
"push-notifications",
|
|
48
|
+
"web-push",
|
|
49
|
+
"iiot"
|
|
50
|
+
],
|
|
51
|
+
"node-red": {
|
|
52
|
+
"version": ">=3.0.0",
|
|
53
|
+
"plugins": {
|
|
54
|
+
"nr-connect": "index.js"
|
|
55
|
+
},
|
|
56
|
+
"nodes": {
|
|
57
|
+
"nr-connect-notify": "nodes/nr-connect-notify.js",
|
|
58
|
+
"ui-nr-connect-profile": "nodes/ui-nr-connect-profile.js"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"node-red-dashboard-2": {
|
|
62
|
+
"version": "1.0.0",
|
|
63
|
+
"widgets": {
|
|
64
|
+
"ui-nr-connect-profile": {
|
|
65
|
+
"output": "ui-nr-connect-profile.umd.js",
|
|
66
|
+
"component": "UINrConnectProfile"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18.0.0"
|
|
72
|
+
},
|
|
73
|
+
"license": "MIT",
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@vue/test-utils": "^2.6.0",
|
|
76
|
+
"happy-dom": "^21.0.4",
|
|
77
|
+
"node-red-node-test-helper": "^0.3.6",
|
|
78
|
+
"vitest": "^3.2.7"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u["ui-nr-connect-profile"]={},u.Vue))})(this,(function(u,s){"use strict";const f="ui-nr-connect-profile-styles",d="13.3.0",g="nr-connect-push",l="Notifications blocked in browser settings — allow in site settings",m=new Map,c=new Map;function y(){if(typeof document>"u"||document.getElementById(f))return;const e=document.createElement("style");e.id=f,e.textContent=`
|
|
2
|
+
.nrc-profile {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
min-width: 0;
|
|
6
|
+
width: 100%;
|
|
7
|
+
}
|
|
8
|
+
.nrc-profile--group {
|
|
9
|
+
gap: 10px;
|
|
10
|
+
padding: 2px 0;
|
|
11
|
+
}
|
|
12
|
+
.nrc-profile--menu {
|
|
13
|
+
gap: 0;
|
|
14
|
+
}
|
|
15
|
+
.nrc-profile-menu-card {
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
border: 1px solid rgba(var(--v-border-color, 128, 128, 128), var(--v-border-opacity, 0.14));
|
|
18
|
+
}
|
|
19
|
+
.nrc-profile-header {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 12px;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
width: 100%;
|
|
25
|
+
}
|
|
26
|
+
.nrc-profile--menu .nrc-profile-header {
|
|
27
|
+
padding: 14px 14px 12px;
|
|
28
|
+
}
|
|
29
|
+
.nrc-profile-text {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 2px;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
flex: 1 1 auto;
|
|
35
|
+
}
|
|
36
|
+
.nrc-profile-name-row {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: 6px;
|
|
40
|
+
min-width: 0;
|
|
41
|
+
}
|
|
42
|
+
.nrc-profile-name {
|
|
43
|
+
font-weight: 600;
|
|
44
|
+
font-size: 0.92rem;
|
|
45
|
+
line-height: 1.25;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
text-overflow: ellipsis;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
}
|
|
50
|
+
.nrc-profile-email {
|
|
51
|
+
opacity: 0.7;
|
|
52
|
+
font-size: 0.8rem;
|
|
53
|
+
line-height: 1.3;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
text-overflow: ellipsis;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
}
|
|
58
|
+
.nrc-profile-local {
|
|
59
|
+
opacity: 0.68;
|
|
60
|
+
font-size: 0.78rem;
|
|
61
|
+
line-height: 1.3;
|
|
62
|
+
}
|
|
63
|
+
.nrc-profile-role {
|
|
64
|
+
flex: 0 0 auto;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
letter-spacing: 0.01em;
|
|
67
|
+
}
|
|
68
|
+
.nrc-profile-divider {
|
|
69
|
+
height: 1px;
|
|
70
|
+
width: 100%;
|
|
71
|
+
background: rgba(var(--v-border-color, 128, 128, 128), var(--v-border-opacity, 0.12));
|
|
72
|
+
}
|
|
73
|
+
.nrc-profile-actions {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
gap: 4px;
|
|
77
|
+
}
|
|
78
|
+
.nrc-profile--menu .nrc-profile-actions {
|
|
79
|
+
padding: 6px;
|
|
80
|
+
}
|
|
81
|
+
.nrc-profile-push-btn {
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
gap: 10px;
|
|
85
|
+
width: 100%;
|
|
86
|
+
padding: 8px 10px;
|
|
87
|
+
border: 1px solid rgba(var(--v-border-color, 128, 128, 128), var(--v-border-opacity, 0.12));
|
|
88
|
+
border-radius: 10px;
|
|
89
|
+
background: transparent;
|
|
90
|
+
color: inherit;
|
|
91
|
+
text-align: left;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
|
|
94
|
+
font: inherit;
|
|
95
|
+
}
|
|
96
|
+
.nrc-profile--menu .nrc-profile-push-btn {
|
|
97
|
+
border-color: transparent;
|
|
98
|
+
border-radius: 8px;
|
|
99
|
+
}
|
|
100
|
+
.nrc-profile-push-btn:hover:not(:disabled) {
|
|
101
|
+
background: rgba(var(--v-theme-on-surface, 128, 128, 128), 0.06);
|
|
102
|
+
}
|
|
103
|
+
.nrc-profile-push-btn:focus-visible {
|
|
104
|
+
outline: 2px solid rgb(var(--v-theme-primary, 25, 118, 210));
|
|
105
|
+
outline-offset: -2px;
|
|
106
|
+
}
|
|
107
|
+
.nrc-profile-push-btn:disabled {
|
|
108
|
+
opacity: 0.6;
|
|
109
|
+
cursor: not-allowed;
|
|
110
|
+
}
|
|
111
|
+
.nrc-profile-bell-badge {
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
width: 32px;
|
|
116
|
+
height: 32px;
|
|
117
|
+
border-radius: 999px;
|
|
118
|
+
flex: 0 0 32px;
|
|
119
|
+
background: rgba(var(--v-theme-on-surface, 128, 128, 128), 0.08);
|
|
120
|
+
color: inherit;
|
|
121
|
+
transition: background-color 140ms ease, color 140ms ease;
|
|
122
|
+
}
|
|
123
|
+
.nrc-profile-push-btn--on .nrc-profile-bell-badge {
|
|
124
|
+
background: rgba(var(--v-theme-primary, 25, 118, 210), 0.14);
|
|
125
|
+
color: rgb(var(--v-theme-primary, 25, 118, 210));
|
|
126
|
+
}
|
|
127
|
+
.nrc-profile-push-btn--blocked .nrc-profile-bell-badge {
|
|
128
|
+
background: rgba(var(--v-theme-error, 176, 0, 32), 0.12);
|
|
129
|
+
color: rgb(var(--v-theme-error, 176, 0, 32));
|
|
130
|
+
}
|
|
131
|
+
.nrc-profile-push-copy {
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
gap: 1px;
|
|
135
|
+
min-width: 0;
|
|
136
|
+
flex: 1 1 auto;
|
|
137
|
+
}
|
|
138
|
+
.nrc-profile-push-label {
|
|
139
|
+
font-size: 0.85rem;
|
|
140
|
+
font-weight: 500;
|
|
141
|
+
line-height: 1.25;
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
text-overflow: ellipsis;
|
|
144
|
+
white-space: nowrap;
|
|
145
|
+
}
|
|
146
|
+
.nrc-profile-push-status {
|
|
147
|
+
font-size: 0.74rem;
|
|
148
|
+
line-height: 1.25;
|
|
149
|
+
opacity: 0.68;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
text-overflow: ellipsis;
|
|
152
|
+
display: -webkit-box;
|
|
153
|
+
-webkit-line-clamp: 2;
|
|
154
|
+
-webkit-box-orient: vertical;
|
|
155
|
+
}
|
|
156
|
+
.nrc-profile-push-pill {
|
|
157
|
+
display: inline-flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
justify-content: center;
|
|
160
|
+
min-width: 34px;
|
|
161
|
+
height: 22px;
|
|
162
|
+
padding: 0 8px;
|
|
163
|
+
border-radius: 999px;
|
|
164
|
+
font-size: 0.72rem;
|
|
165
|
+
font-weight: 600;
|
|
166
|
+
letter-spacing: 0.02em;
|
|
167
|
+
flex: 0 0 auto;
|
|
168
|
+
background: rgba(var(--v-theme-on-surface, 128, 128, 128), 0.09);
|
|
169
|
+
color: inherit;
|
|
170
|
+
opacity: 0.82;
|
|
171
|
+
}
|
|
172
|
+
.nrc-profile-push-btn--on .nrc-profile-push-pill {
|
|
173
|
+
background: rgba(var(--v-theme-primary, 25, 118, 210), 0.15);
|
|
174
|
+
color: rgb(var(--v-theme-primary, 25, 118, 210));
|
|
175
|
+
opacity: 1;
|
|
176
|
+
}
|
|
177
|
+
.nrc-profile-push-btn--blocked .nrc-profile-push-pill {
|
|
178
|
+
background: rgba(var(--v-theme-error, 176, 0, 32), 0.12);
|
|
179
|
+
color: rgb(var(--v-theme-error, 176, 0, 32));
|
|
180
|
+
opacity: 1;
|
|
181
|
+
}
|
|
182
|
+
.nrc-profile-spinner {
|
|
183
|
+
width: 12px;
|
|
184
|
+
height: 12px;
|
|
185
|
+
border: 2px solid currentColor;
|
|
186
|
+
border-right-color: transparent;
|
|
187
|
+
border-radius: 999px;
|
|
188
|
+
animation: nrc-spin 650ms linear infinite;
|
|
189
|
+
}
|
|
190
|
+
@keyframes nrc-spin {
|
|
191
|
+
to { transform: rotate(360deg); }
|
|
192
|
+
}
|
|
193
|
+
.nrc-profile-signout-row {
|
|
194
|
+
padding: 6px;
|
|
195
|
+
}
|
|
196
|
+
.nrc-profile-signout {
|
|
197
|
+
justify-content: flex-start;
|
|
198
|
+
text-transform: none;
|
|
199
|
+
letter-spacing: 0;
|
|
200
|
+
font-weight: 500;
|
|
201
|
+
}
|
|
202
|
+
.nrc-profile--group .nrc-profile-signout {
|
|
203
|
+
align-self: flex-start;
|
|
204
|
+
}
|
|
205
|
+
.nrc-profile-initials {
|
|
206
|
+
font-weight: 600;
|
|
207
|
+
font-size: 0.85rem;
|
|
208
|
+
color: rgb(var(--v-theme-on-primary, 255, 255, 255));
|
|
209
|
+
}
|
|
210
|
+
.nrc-profile-trigger {
|
|
211
|
+
position: relative;
|
|
212
|
+
}
|
|
213
|
+
`,document.head.appendChild(e)}function S(e,t){const i=typeof e=="string"?e.trim():"";if(i){const r=i.split(/\s+/).filter(Boolean);if(r.length===1)return r[0].charAt(0).toUpperCase();if(r.length>1)return(r[0].charAt(0)+r[r.length-1].charAt(0)).toUpperCase()}const n=typeof t=="string"?t.trim():"";return n?n.charAt(0).toUpperCase():""}function v(){if(typeof Notification>"u"||typeof Notification.requestPermission!="function")return Promise.resolve("denied");try{let e=!1,t;const i=new Promise(r=>{t=o=>{e||(e=!0,r(o||Notification.permission||"default"))}}),n=Notification.requestPermission(r=>{t(r)});return n&&typeof n.then=="function"&&n.then(r=>t(r),()=>t(Notification.permission==="granted"?"granted":"denied")),i}catch{return Promise.resolve("denied")}}function p(e){return`nrc_push_sync_v1:${typeof window<"u"?window.location.origin:""}${e}`}function P(e){try{if(typeof localStorage>"u")return null;const t=localStorage.getItem(p(e));if(!t)return null;const i=JSON.parse(t);if(i&&typeof i.token=="string"&&typeof i.syncedAt=="number")return i}catch{}return null}function b(e,t,i){try{if(typeof localStorage>"u")return;localStorage.setItem(p(e),JSON.stringify({token:t,email:i||"",syncedAt:Date.now()}))}catch{}}function w(e){try{if(typeof localStorage>"u")return;localStorage.removeItem(p(e))}catch{}}const x={name:"UINrConnectProfile",inject:{$socket:{default:null}},props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!0,visible:!0})}},data(){return{loading:!0,user:null,local:!0,signOutBaseUrl:null,imgFailed:!1,basePath:"/dashboard",teleportReady:!1,loadError:!1,isUnmounted:!1,pushConfig:null,pushConfigLoaded:!1,pushConfigured:null,pushSupported:!0,pushState:!1,pushEnabled:!1,pushLoading:!1,pushStatus:"",currentToken:null,signingOut:!1}},computed:{displayName(){return this.loadError?"Profile unavailable":this.user?.name||this.user?.email||"Local access"},initials(){return S(this.user?.name,this.user?.email)},showPhoto(){return!!this.user?.photoUrl&&!this.imgFailed},signOutHref(){if(this.local||!this.signOutBaseUrl||this.props.showSignOut===!1)return null;const e=typeof window<"u"?window.location.origin:"";return`${this.signOutBaseUrl}?redirect=${encodeURIComponent(e+this.basePath)}`},roleLabel(){const e=this.user?.role;return typeof e!="string"||!e?"":e.charAt(0).toUpperCase()+e.slice(1)},pushFeatureEnabled(){return this.props.showPushToggle!==!1&&!this.loading&&!!this.user?.email},showPushSection(){return this.pushFeatureEnabled?this.pushSupported?this.pushConfigured===!0:!0:!1},pushLabel(){return this.props.pushLabel||"Push Notifications"},displayedPushStatus(){return this.props.showPushStatus!==!1?this.pushStatus:""},pushBlocked(){return!this.pushSupported||typeof Notification<"u"&&Notification.permission==="denied"?!0:this.pushStatus===l},pushBellIcon(){return this.pushBlocked?"mdi-bell-off-outline":this.pushState?"mdi-bell-ring":"mdi-bell-outline"},pushPillText(){return this.pushSupported?this.pushBlocked?"Blocked":this.pushState?"On":"Off":"N/A"}},async mounted(){if(y(),this.basePath=this.resolveBasePath(),this.props.placement==="appbar"){if(await s.nextTick(),this.isUnmounted)return;this.checkOrObserveAppBar()}await this.loadProfile(),!this.isUnmounted&&this.pushFeatureEnabled&&await this.initializePush()},unmounted(){this.isUnmounted=!0,this._teleportObserver&&(this._teleportObserver.disconnect(),this._teleportObserver=null),typeof this._unsubscribeOnMessage=="function"&&(this._unsubscribeOnMessage(),this._unsubscribeOnMessage=null),this._permissionStatus&&(this._permissionStatus.onchange=null,this._permissionStatus=null)},methods:{resolveBasePath(){const e=this.$store?.state?.setup?.setup?.socketio?.path;if(typeof e=="string"&&e.includes("/socket.io")){const t=e.replace(/\/socket\.io.*$/,"");if(t)return t}return typeof window<"u"&&window.location.pathname.startsWith("/ui")?"/ui":"/dashboard"},send(e){this.$socket?.emit?.("widget-action",this.id,e)},checkOrObserveAppBar(){if(typeof document>"u")return;if(document.querySelector("#app-bar-actions")){this.teleportReady=!0;return}if(typeof MutationObserver>"u"||!document.body){console.warn("[NR Connect] #app-bar-actions not found; is the dashboard title bar hidden?");return}const e=new MutationObserver(()=>{this.isUnmounted||document.querySelector("#app-bar-actions")&&(this.teleportReady=!0,e.disconnect(),this._teleportObserver=null)});this._teleportObserver=e,e.observe(document.body,{childList:!0,subtree:!0})},async fetchProfileData(){const e=m.get(this.basePath);if(e&&Date.now()-e.fetchedAt<6e4)return e.data;if(c.has(this.basePath))return c.get(this.basePath);const t=(async()=>{const i=await fetch(`${this.basePath}/_nrc/me`,{credentials:"same-origin",cache:"no-store"});if(!i.ok)throw new Error(`HTTP ${i.status}`);const n=await i.json();return m.set(this.basePath,{fetchedAt:Date.now(),data:n}),n})();c.set(this.basePath,t);try{return await t}finally{c.delete(this.basePath)}},async loadProfile(){try{const e=await this.fetchProfileData();if(this.isUnmounted)return;this.user=e?.user||null,this.local=!!(e?.local??!this.user),this.signOutBaseUrl=e?.signOutBaseUrl||null,this.imgFailed=!1,this.loadError=!1}catch{if(this.isUnmounted)return;this.loadError=!0,this.user=null,this.local=!0,this.signOutBaseUrl=null}finally{this.isUnmounted||(this.loading=!1)}},async loadFirebaseModules(){if(this._firebaseModules)return this._firebaseModules;const[e,t]=await Promise.all([import(`https://www.gstatic.com/firebasejs/${d}/firebase-app.js`),import(`https://www.gstatic.com/firebasejs/${d}/firebase-messaging.js`)]);return this._firebaseModules={appMod:e,msgMod:t},this._firebaseModules},async ensureFirebaseMessaging(){const{appMod:e,msgMod:t}=await this.loadFirebaseModules();if(!await t.isSupported())throw new Error("Push notifications are not supported in this browser");const r=e.getApps().find(o=>o.name===g)||e.initializeApp(this.pushConfig.firebaseConfig,g);return this._messaging||(this._messaging=t.getMessaging(r)),{msgMod:t,messaging:this._messaging}},getServiceWorkerScope(){return`${this.basePath}/nr-connect-push-scope`},async getExistingServiceWorkerRegistration(){if(this._swRegistration)return this._swRegistration;if(typeof navigator>"u"||!navigator.serviceWorker||typeof navigator.serviceWorker.getRegistration!="function")return null;try{const e=await navigator.serviceWorker.getRegistration(this.getServiceWorkerScope());if(e&&e.active)return this._swRegistration=e,e}catch{}return null},async ensureServiceWorker(){if(this._swRegistration)return this._swRegistration;const e=`${this.basePath}/nr-connect-push-sw.js`,t=this.getServiceWorkerScope(),i=await navigator.serviceWorker.register(e,{scope:t});return i.active||await new Promise((n,r)=>{const o=i.installing||i.waiting;if(!o){n();return}const a=setTimeout(()=>{r(new Error("Push notification setup timed out"))},1e4);o.addEventListener("statechange",()=>{o.state==="activated"?(clearTimeout(a),n()):o.state==="redundant"&&(clearTimeout(a),r(new Error("Push notification setup failed")))})}),this._swRegistration=i,i},async ensurePushConfigLoaded(){if(this.pushConfigLoaded)return this.pushConfigured===!0;try{const e=await fetch(`${this.basePath}/_fcm/config`,{credentials:"same-origin"}),t=await e.json();return this.isUnmounted?!1:(this.pushConfigLoaded=!0,!e.ok||!t?.configured||!t?.firebaseConfig||!t?.vapidKey?(this.pushConfigured=!1,this.pushConfig=null,!1):(this.pushConfig=t,this.pushConfigured=!0,!0))}catch{return this.isUnmounted||(this.pushConfigLoaded=!1,this.pushConfigured=!1,this.pushStatus="Unable to load push configuration"),!1}},async initializePush(){if(!(typeof window>"u")){if(!window.isSecureContext){this.pushSupported=!1,this.pushEnabled=!1,this.pushStatus="Push notifications require HTTPS";return}if(!("serviceWorker"in navigator)||!("PushManager"in window)||!("Notification"in window)){this.pushSupported=!1,this.pushEnabled=!1,this.pushStatus="Push notifications are not supported in this browser";return}if(this.pushSupported=!0,Notification.permission==="denied"){this.pushStatus=l,this.pushState=!1,this.pushEnabled=!0,this.watchPermissionChanges(),this.props.placement!=="appbar"&&await this.ensurePushConfigLoaded();return}if(Notification.permission==="granted"){const e=await this.getExistingServiceWorkerRegistration();if(this.isUnmounted)return;const t=e?await e.pushManager?.getSubscription?.().catch(()=>null):null;if(this.isUnmounted)return;if(t){const i=await this.ensurePushConfigLoaded();if(this.isUnmounted||!i)return;try{const{msgMod:n,messaging:r}=await this.ensureFirebaseMessaging();if(this.isUnmounted)return;if(this.attachForegroundListener(n,r),this.pushEnabled=!0,this.pushState=!0,this.pushStatus="Subscribed for push alerts",this.watchPermissionChanges(),this.props.autoSyncPush!==!1){const o=await n.getToken(r,{vapidKey:this.pushConfig.vapidKey,serviceWorkerRegistration:e});if(this.isUnmounted)return;if(o){this.currentToken=o;const a=P(this.basePath),h=this.user?.email||"";if(!(a&&a.token===o&&a.email===h&&Date.now()-a.syncedAt<432e5)){if(await this.syncTokenWithServer(o,"POST"),this.isUnmounted)return;b(this.basePath,o,h)}}}}catch(n){if(this.isUnmounted)return;this.pushState=!1,this.pushEnabled=!0,this.pushStatus=n?.message||"Push initialization failed"}return}}if(this.pushState=!1,this.pushStatus="Off — toggle to enable push alerts",this.props.placement!=="appbar"){const e=await this.ensurePushConfigLoaded();if(this.isUnmounted||!e)return;this.pushEnabled=!0,this.watchPermissionChanges()}}},async ensurePushReadyForMenu(){if(!(!this.pushFeatureEnabled||!this.pushSupported)&&!this.pushConfigLoaded){const e=await this.ensurePushConfigLoaded();if(this.isUnmounted||!e)return;this.pushEnabled=!0,this.pushStatus||(this.pushStatus=Notification.permission==="denied"?l:"Off — toggle to enable push alerts"),this.watchPermissionChanges()}},attachForegroundListener(e,t){this._unsubscribeOnMessage&&this._unsubscribeOnMessage(),this._unsubscribeOnMessage=e.onMessage(t,i=>{this.send({topic:"push",payload:i})})},async syncTokenWithServer(e,t){const i=await fetch(`${this.basePath}/_fcm/register`,{method:t,credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})}),n=await i.json().catch(()=>({}));if(!i.ok)throw new Error(n?.error||`Server returned HTTP ${i.status}`);return n},async watchPermissionChanges(){if(!(typeof navigator>"u"||!navigator.permissions||typeof navigator.permissions.query!="function"||this._permissionStatus))try{const e=await navigator.permissions.query({name:"notifications"});if(this.isUnmounted)return;this._permissionStatus=e,e.onchange=()=>{this.syncPermissionState()}}catch{}},syncPermissionState(){typeof Notification>"u"||(Notification.permission==="denied"?(this.pushState=!1,this.currentToken=null,w(this.basePath),this.pushStatus=l):this.pushState||(this.pushStatus="Off — toggle to enable push alerts"))},async unregisterCurrentBrowserPush(){let e=this.currentToken,t=null;this.pushConfig&&(this._messaging||e||Notification.permission==="granted")&&(t=await this.ensureFirebaseMessaging().catch(()=>null));const i=this._swRegistration||await this.getExistingServiceWorkerRegistration();if(!e&&t&&i&&Notification.permission==="granted"&&(e=await t.msgMod.getToken(t.messaging,{vapidKey:this.pushConfig.vapidKey,serviceWorkerRegistration:i}).catch(()=>null)),e&&await this.syncTokenWithServer(e,"DELETE").catch(()=>{}),t&&await t.msgMod.deleteToken(t.messaging).catch(()=>{}),i){const n=await i.pushManager?.getSubscription?.().catch(()=>null);n&&await n.unsubscribe().catch(()=>{})}w(this.basePath),this.currentToken=null},async onPushToggle(e){if(this.pushLoading)return;const t=!!e;let i=null;if(t){if(typeof Notification>"u"||typeof Notification.requestPermission!="function"){this.pushState=!1,this.pushStatus="Push notifications are not supported in this browser";return}i=v()}this.pushLoading=!0,this.pushEnabled=!1,this.pushStatus=t?"Requesting notification permission...":"Updating push subscription...";try{if(t){const r=await i;if(this.isUnmounted)return;if(r!=="granted"){this.pushState=!1,this.pushStatus=r==="denied"?l:"Permission prompt dismissed";return}}const n=await this.ensurePushConfigLoaded();if(this.isUnmounted)return;if(!n)throw new Error("Push notifications are not configured on the portal");if(t){const{msgMod:r,messaging:o}=await this.ensureFirebaseMessaging();if(this.isUnmounted)return;const a=await this.ensureServiceWorker();if(this.isUnmounted)return;this.attachForegroundListener(r,o);const h=await r.getToken(o,{vapidKey:this.pushConfig.vapidKey,serviceWorkerRegistration:a});if(this.isUnmounted)return;if(!h)throw new Error("Could not register this browser for push notifications");if(await this.syncTokenWithServer(h,"POST"),this.isUnmounted)return;b(this.basePath,h,this.user?.email||""),this.currentToken=h,this.pushState=!0,this.pushStatus="Subscribed for push alerts",this.send({topic:"push_subscribed",payload:{subscribed:!0}})}else{if(await this.unregisterCurrentBrowserPush(),this.isUnmounted)return;this.pushState=!1,this.pushStatus="Unsubscribed from push alerts",this.send({topic:"push_unsubscribed",payload:{subscribed:!1}})}}catch(n){if(this.isUnmounted)return;this.pushState=!t,this.pushStatus=n?.message||"Failed to update push subscription"}finally{this.isUnmounted||(this.pushLoading=!1,this.pushEnabled=!0)}},async onSignOutClick(e){if(!(!this.signOutHref||this.signingOut)&&!(!this.pushState&&!this.currentToken)){e&&typeof e.preventDefault=="function"&&e.preventDefault(),this.signingOut=!0;try{await Promise.race([this.unregisterCurrentBrowserPush().catch(()=>{}),new Promise(t=>setTimeout(t,1500))])}finally{typeof window<"u"&&window.location&&window.location.assign(this.signOutHref)}}},renderAvatar(e){const t=s.resolveComponent("v-avatar"),i=s.resolveComponent("v-icon");return s.h(t,{size:e,color:"primary"},()=>this.loading?s.h("span",{class:"nrc-profile-initials"},""):this.showPhoto?s.h("img",{src:this.user.photoUrl,alt:"",referrerpolicy:"no-referrer",onError:()=>{this.imgFailed=!0},style:"width:100%;height:100%;object-fit:cover"}):this.initials?s.h("span",{class:"nrc-profile-initials"},this.initials):s.h(i,{icon:"mdi-account"}))},renderIdentityDetails(){const e=s.resolveComponent("v-chip"),t=[s.h("div",{class:"nrc-profile-name"},this.displayName)];this.props.showRole!==!1&&this.user?.role&&!this.local&&t.push(s.h(e,{size:"x-small",variant:"tonal",color:"primary",label:!0,class:"nrc-profile-role"},()=>this.roleLabel));const i=[s.h("div",{class:"nrc-profile-name-row"},t)];return this.props.showEmail!==!1&&this.user?.email&&i.push(s.h("div",{class:"nrc-profile-email"},this.user.email)),this.loadError?i.push(s.h("div",{class:"nrc-profile-local"},"Could not load account details")):this.local&&!this.user&&i.push(s.h("div",{class:"nrc-profile-local"},"Direct connection")),i},renderPushSwitch(){if(!this.showPushSection)return null;const e=s.resolveComponent("v-icon"),t=!this.pushEnabled||!this.pushSupported||this.pushLoading||this.state?.enabled===!1,i=[s.h("span",{class:"nrc-profile-push-label"},this.pushLabel)];this.displayedPushStatus&&i.push(s.h("span",{class:"nrc-profile-push-status"},this.displayedPushStatus));const n=["nrc-profile-push-btn",this.pushState?"nrc-profile-push-btn--on":"",this.pushBlocked?"nrc-profile-push-btn--blocked":""].filter(Boolean);return s.h("div",{class:"nrc-profile-push"},[s.h("button",{type:"button",role:"switch","aria-checked":String(this.pushState),"aria-busy":String(this.pushLoading),"aria-label":`${this.pushLabel}: ${this.pushPillText}`,disabled:t,class:n,onClick:()=>{if(t)return;const r=!this.pushState;this.pushState=r,this.onPushToggle(r)}},[s.h("span",{class:"nrc-profile-bell-badge","aria-hidden":"true"},[s.h(e,{icon:this.pushBellIcon,size:18})]),s.h("span",{class:"nrc-profile-push-copy"},i),s.h("span",{class:"nrc-profile-push-pill"},[this.pushLoading?s.h("span",{class:"nrc-profile-spinner","aria-hidden":"true"}):this.pushPillText])])])},renderSignOutButton(e=!1){if(!this.signOutHref)return null;const t=s.resolveComponent("v-btn");return s.h(t,{href:this.signOutHref,variant:e?"text":"tonal",size:"small",block:e,rounded:"lg",prependIcon:"mdi-logout",loading:this.signingOut,class:"nrc-profile-signout",onClick:i=>this.onSignOutClick(i)},()=>"Sign out")}},render(){if(this.state?.visible===!1)return null;if(this.props.placement==="appbar"){if(!this.teleportReady)return null;const t=s.resolveComponent("v-menu"),i=s.resolveComponent("v-btn"),n=s.resolveComponent("v-card"),r=[s.h("div",{class:"nrc-profile-header"},[this.renderAvatar(44),s.h("div",{class:"nrc-profile-text"},this.loading?[]:this.renderIdentityDetails())])];if(!this.loading){const a=this.renderPushSwitch();a&&(r.push(s.h("div",{class:"nrc-profile-divider"})),r.push(s.h("div",{class:"nrc-profile-actions"},[a])));const h=this.renderSignOutButton(!0);h&&(r.push(s.h("div",{class:"nrc-profile-divider"})),r.push(s.h("div",{class:"nrc-profile-signout-row"},[h])))}const o=s.h(t,{location:"bottom end",offset:8,closeOnContentClick:!1,"onUpdate:modelValue":a=>{a&&this.ensurePushReadyForMenu()}},{activator:({props:a})=>s.h(i,{...a,icon:!0,variant:"text","aria-label":`Account: ${this.displayName}`,class:"nrc-profile-trigger"},()=>this.renderAvatar(32)),default:()=>s.h(n,{width:280,rounded:"lg",elevation:6,class:"nrc-profile-menu nrc-profile-menu-card"},()=>s.h("div",{class:"nrc-profile nrc-profile--menu"},r))});return s.h(s.Teleport,{to:"#app-bar-actions"},[o])}const e=[s.h("div",{class:"nrc-profile-header"},[this.renderAvatar(40),s.h("div",{class:"nrc-profile-text"},this.loading?[]:this.renderIdentityDetails())])];if(!this.loading){const t=this.renderPushSwitch();t&&e.push(t);const i=this.renderSignOutButton(!1);i&&e.push(i)}return s.h("div",{class:"nrc-profile nrc-profile--group"},e)}};u.UINrConnectProfile=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|