каркас вроде есть
This commit is contained in:
@@ -6,68 +6,29 @@ var ReactDom = tslib_1.__importStar(require("react-dom"));
|
||||
var sp_core_library_1 = require("@microsoft/sp-core-library");
|
||||
var sp_property_pane_1 = require("@microsoft/sp-property-pane");
|
||||
var sp_webpart_base_1 = require("@microsoft/sp-webpart-base");
|
||||
var strings = tslib_1.__importStar(require("ApprovalAdminWebPartStrings"));
|
||||
var ApprovalAdmin_1 = tslib_1.__importDefault(require("./components/ApprovalAdmin"));
|
||||
var ApprovalAdminWebPart = /** @class */ (function (_super) {
|
||||
tslib_1.__extends(ApprovalAdminWebPart, _super);
|
||||
function ApprovalAdminWebPart() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this._isDarkTheme = false;
|
||||
_this._environmentMessage = '';
|
||||
return _this;
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
ApprovalAdminWebPart.prototype.render = function () {
|
||||
var element = React.createElement(ApprovalAdmin_1.default, {
|
||||
description: this.properties.description,
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
environmentMessage: this._environmentMessage,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
userDisplayName: this.context.pageContext.user.displayName
|
||||
context: this.context,
|
||||
apiBaseUrl: this.properties.apiBaseUrl,
|
||||
useDevAuth: this.properties.useDevAuth,
|
||||
devUserEmail: this.properties.devUserEmail,
|
||||
aadResourceId: this.properties.aadResourceId
|
||||
});
|
||||
ReactDom.render(element, this.domElement);
|
||||
};
|
||||
ApprovalAdminWebPart.prototype.onInit = function () {
|
||||
var _this = this;
|
||||
return this._getEnvironmentMessage().then(function (message) {
|
||||
_this._environmentMessage = message;
|
||||
});
|
||||
};
|
||||
ApprovalAdminWebPart.prototype._getEnvironmentMessage = function () {
|
||||
var _this = this;
|
||||
if (!!this.context.sdks.microsoftTeams) { // running in Teams, office.com or Outlook
|
||||
return this.context.sdks.microsoftTeams.teamsJs.app.getContext()
|
||||
.then(function (context) {
|
||||
var environmentMessage = '';
|
||||
switch (context.app.host.name) {
|
||||
case 'Office': // running in Office
|
||||
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOffice : strings.AppOfficeEnvironment;
|
||||
break;
|
||||
case 'Outlook': // running in Outlook
|
||||
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentOutlook : strings.AppOutlookEnvironment;
|
||||
break;
|
||||
case 'Teams': // running in Teams
|
||||
case 'TeamsModern':
|
||||
environmentMessage = _this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentTeams : strings.AppTeamsTabEnvironment;
|
||||
break;
|
||||
default:
|
||||
environmentMessage = strings.UnknownEnvironment;
|
||||
}
|
||||
return environmentMessage;
|
||||
});
|
||||
}
|
||||
return Promise.resolve(this.context.isServedFromLocalhost ? strings.AppLocalEnvironmentSharePoint : strings.AppSharePointEnvironment);
|
||||
};
|
||||
ApprovalAdminWebPart.prototype.onThemeChanged = function (currentTheme) {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
var semanticColors = currentTheme.semanticColors;
|
||||
if (semanticColors) {
|
||||
this.domElement.style.setProperty('--bodyText', semanticColors.bodyText || null);
|
||||
this.domElement.style.setProperty('--link', semanticColors.link || null);
|
||||
this.domElement.style.setProperty('--linkHovered', semanticColors.linkHovered || null);
|
||||
}
|
||||
var _a;
|
||||
this.properties.apiBaseUrl = this.properties.apiBaseUrl || 'https://localhost:5443';
|
||||
this.properties.useDevAuth = (_a = this.properties.useDevAuth) !== null && _a !== void 0 ? _a : true;
|
||||
this.properties.devUserEmail = this.properties.devUserEmail || 'dev@tnsu.kz';
|
||||
this.properties.aadResourceId = this.properties.aadResourceId || 'api://9232d9e2-9807-4753-808f-07250e5474b0';
|
||||
return Promise.resolve();
|
||||
};
|
||||
ApprovalAdminWebPart.prototype.onDispose = function () {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
@@ -84,14 +45,28 @@ var ApprovalAdminWebPart = /** @class */ (function (_super) {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
description: 'Подключение к Tnsu.ApprovalRoute.Api'
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupName: 'API',
|
||||
groupFields: [
|
||||
(0, sp_property_pane_1.PropertyPaneTextField)('description', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
(0, sp_property_pane_1.PropertyPaneTextField)('apiBaseUrl', {
|
||||
label: 'Api Base Url',
|
||||
description: 'Например, https://localhost:5443 локально или прод-адрес API.'
|
||||
}),
|
||||
(0, sp_property_pane_1.PropertyPaneToggle)('useDevAuth', {
|
||||
label: 'Локальный Dev-режим (без Azure AD)',
|
||||
onText: 'Вкл. (заголовок X-Dev-User-Email)',
|
||||
offText: 'Выкл. (AAD-токен через SPFx)'
|
||||
}),
|
||||
(0, sp_property_pane_1.PropertyPaneTextField)('devUserEmail', {
|
||||
label: 'Dev: email пользователя',
|
||||
description: 'Используется только при включённом Dev-режиме.'
|
||||
}),
|
||||
(0, sp_property_pane_1.PropertyPaneTextField)('aadResourceId', {
|
||||
label: 'AAD Resource Id (App ID URI)',
|
||||
description: 'Используется только при выключенном Dev-режиме. Должен совпадать с webApiPermissionRequests в package-solution.json.'
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user