Skip to content
Projects
Groups
Snippets
Help
Sign in / Register
Toggle navigation
Minds Frontend
Project overview
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
344
Merge Requests
56
CI / CD
Security & Compliance
Packages
Wiki
Snippets
Members
Collapse sidebar
Close sidebar
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Commits
6a3dac72
Commit
6a3dac72
authored
18 minutes ago
by
Mark Harding
Browse files
Options
Download
(fix): plotly fix, preparation for full server bundle and xsrf token re-introduced
parent
4399c6bc
epic/SSR
1 merge request
!343
WIP: Epic/ssr
Pipeline
#108487513
failed with stages
in 3 minutes and 39 seconds
Changes
11
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
41 deletions
+66
-41
src/app/app.browser.module.ts
View file @
6a3dac72
...
...
@@ -5,11 +5,12 @@ import { Minds } from './app.component';
import
*
as
PlotlyJS
from
'
plotly.js/dist/plotly.js
'
;
import
{
PlotlyModule
}
from
'
angular-plotly.js
'
;
import
{
CookieModule
}
from
'
@gorniv/ngx-universal
'
;
PlotlyModule
.
plotlyjs
=
PlotlyJS
;
@
NgModule
({
imports
:
[
MindsModule
,
PlotlyModule
],
imports
:
[
MindsModule
,
PlotlyModule
,
CookieModule
],
bootstrap
:
[
Minds
],
providers
:
[{
provide
:
'
ORIGIN_URL
'
,
useValue
:
location
.
origin
}],
})
...
...
This diff is collapsed.
src/app/app.module.ts
View file @
6a3dac72
...
...
@@ -77,6 +77,7 @@ import { ChannelContainerModule } from './modules/channel-container/channel-cont
import
{
UpgradesModule
}
from
'
./modules/upgrades/upgrades.module
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
CookieModule
}
from
'
@gorniv/ngx-universal
'
;
Sentry
.
init
({
dsn
:
'
https://3f786f8407e042db9053434a3ab527a2@sentry.io/1538008
'
,
// TODO: do not hardcard
...
...
@@ -106,6 +107,7 @@ export class SentryErrorHandler implements ErrorHandler {
imports
:
[
BrowserModule
.
withServerTransition
({
appId
:
'
m-app
'
}),
BrowserTransferStateModule
,
CookieModule
.
forRoot
(),
// TransferHttpCacheModule,
//BrowserAnimationsModule,
ReactiveFormsModule
,
...
...
This diff is collapsed.
src/app/app.server.module.ts
View file @
6a3dac72
...
...
@@ -8,6 +8,13 @@ import * as xhr2 from 'xhr2';
import
{
MindsModule
}
from
'
./app.module
'
;
import
{
Minds
}
from
'
./app.component
'
;
import
{
PlotlyModule
}
from
'
angular-plotly.js
'
;
import
{
CookieService
,
CookieBackendService
}
from
'
@gorniv/ngx-universal
'
;
PlotlyModule
.
plotlyjs
=
{
plot
:
()
=>
{
// This simply satisfies the isValid() error
},
};
// activate cookie for server-side rendering
export
class
ServerXhr
implements
XhrFactory
{
...
...
@@ -25,7 +32,13 @@ export class ServerXhr implements XhrFactory {
ServerTransferStateModule
,
PlotlyModule
,
],
providers
:
[{
provide
:
XhrFactory
,
useClass
:
ServerXhr
}],
providers
:
[
{
provide
:
XhrFactory
,
useClass
:
ServerXhr
},
{
provide
:
CookieService
,
useClass
:
CookieBackendService
,
},
],
bootstrap
:
[
Minds
],
})
export
class
AppServerModule
{}
This diff is collapsed.
src/app/common/api/client.service.ts
View file @
6a3dac72
...
...
@@ -7,13 +7,12 @@ import { environment } from '../../../environments/environment';
*/
export
class
MindsHttpClient
{
base
:
string
=
'
/
'
;
cookie
:
Cookie
=
new
Cookie
();
static
_
(
http
:
HttpClient
)
{
return
new
MindsHttpClient
(
http
);
static
_
(
http
:
HttpClient
,
cookie
:
Cookie
)
{
return
new
MindsHttpClient
(
http
,
cookie
);
}
constructor
(
public
http
:
HttpClient
)
{}
constructor
(
public
http
:
HttpClient
,
private
cookie
:
Cookie
)
{}
/**
* Return a GET request
...
...
This diff is collapsed.
src/app/common/common.module.ts
View file @
6a3dac72
...
...
@@ -132,6 +132,7 @@ import { FormToastComponent } from './components/form-toast/form-toast.component
import
{
SsoService
}
from
'
./services/sso.service
'
;
import
{
EmailConfirmationComponent
}
from
'
./components/email-confirmation/email-confirmation.component
'
;
import
{
ConfigsService
}
from
'
./services/configs.service
'
;
import
{
Cookie
}
from
'
../services/cookie
'
;
const
routes
:
Routes
=
[
{
...
...
@@ -375,7 +376,7 @@ const routes: Routes = [
{
provide
:
MindsHttpClient
,
useFactory
:
MindsHttpClient
.
_
,
deps
:
[
HttpClient
],
deps
:
[
HttpClient
,
Cookie
],
},
{
provide
:
NSFWSelectorCreatorService
,
...
...
This diff is collapsed.
src/app/modules/channels/channel.component.ts
View file @
6a3dac72
...
...
@@ -77,7 +77,7 @@ export class ChannelComponent {
this
.
editing
=
false
;
if
(
params
[
'
username
'
])
{
this
.
changed
=
this
.
user
.
user
name
!==
params
[
'
username
'
];
this
.
changed
=
this
.
username
!==
params
[
'
username
'
];
this
.
username
=
params
[
'
username
'
];
feedChanged
=
true
;
...
...
This diff is collapsed.
src/app/services/api/client.ts
View file @
6a3dac72
...
...
@@ -12,21 +12,29 @@ import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
*/
export
class
Client
{
base
:
string
=
'
/
'
;
cookie
:
Cookie
=
new
Cookie
();
static
_
(
http
:
HttpClient
,
location
:
Location
,
cookie
:
Cookie
,
platformId
,
transferState
:
TransferState
,
@
Inject
(
'
ORIGIN_URL
'
)
baseUrl
:
string
)
{
return
new
Client
(
http
,
location
,
platformId
,
transferState
,
baseUrl
);
return
new
Client
(
http
,
location
,
cookie
,
platformId
,
transferState
,
baseUrl
);
}
constructor
(
public
http
:
HttpClient
,
public
location
:
Location
,
private
cookie
:
Cookie
,
@
Inject
(
PLATFORM_ID
)
private
platformId
,
private
transferState
:
TransferState
,
@
Inject
(
'
ORIGIN_URL
'
)
public
baseUrl
:
string
...
...
@@ -251,11 +259,6 @@ export class Client {
* Build the options
*/
private
buildOptions
(
options
:
Object
,
withCredentials
:
boolean
=
false
)
{
if
(
isPlatformServer
(
this
.
platformId
))
{
return
{
withCredentials
:
true
,
};
}
const
XSRF_TOKEN
=
this
.
cookie
.
get
(
'
XSRF-TOKEN
'
)
||
''
;
const
headers
=
{
...
...
This diff is collapsed.
src/app/services/api/upload.ts
View file @
6a3dac72
...
...
@@ -6,13 +6,12 @@ import { HttpClient } from '@angular/common/http';
*/
export
class
Upload
{
base
:
string
=
'
/
'
;
cookie
:
Cookie
=
new
Cookie
();
static
_
(
http
:
HttpClient
)
{
return
new
Upload
(
http
);
static
_
(
http
:
HttpClient
,
cookie
:
Cookie
)
{
return
new
Upload
(
http
,
cookie
);
}
constructor
(
public
http
:
HttpClient
)
{}
constructor
(
public
http
:
HttpClient
,
private
cookie
:
Cookie
)
{}
/**
* Return a POST request
...
...
This diff is collapsed.
src/app/services/cookie.ts
View file @
6a3dac72
import
{
CookieService
}
from
'
@gorniv/ngx-universal
'
;
import
{
Injectable
}
from
'
@angular/core
'
;
/**
* A very simple cookie service
*/
@
Injectable
()
export
class
Cookie
{
constructor
(
private
cookieService
:
CookieService
)
{}
/**
* Return a cookie by name
*/
get
(
key
:
string
):
string
{
var
cookies
:
Array
<
string
>
=
document
.
cookie
?
document
.
cookie
.
split
(
'
;
'
)
:
[];
return
this
.
cookieService
.
get
(
key
);
// var cookies: Array<string> = document.cookie
// ? document.cookie.split('; ')
// : [];
if
(
!
cookies
)
return
;
//
if (!cookies) return;
for
(
let
cookie
of
cookies
)
{
let
name
:
string
,
value
:
string
;
[
name
,
value
]
=
cookie
.
split
(
'
=
'
);
if
(
name
===
key
)
return
value
;
}
return
;
//
for (let cookie of cookies) {
//
let name: string, value: string;
//
[name, value] = cookie.split('=');
//
if (name === key) return value;
//
}
//
return;
}
}
This diff is collapsed.
src/app/services/providers.ts
View file @
6a3dac72
...
...
@@ -50,6 +50,7 @@ import { FormToastService } from '../common/services/form-toast.service';
import
{
ConfigsService
}
from
'
../common/services/configs.service
'
;
import
{
TransferHttpInterceptorService
}
from
'
./transfer-http-interceptor.service
'
;
import
{
CookieHttpInterceptorService
}
from
'
./api/cookie-http-interceptor.service
'
;
import
{
Cookie
}
from
'
./cookie
'
;
export
const
MINDS_PROVIDERS
:
any
[]
=
[
SiteService
,
...
...
@@ -71,12 +72,19 @@ export const MINDS_PROVIDERS: any[] = [
{
provide
:
Client
,
useFactory
:
Client
.
_
,
deps
:
[
HttpClient
,
Location
,
PLATFORM_ID
,
TransferState
,
'
ORIGIN_URL
'
],
deps
:
[
HttpClient
,
Location
,
Cookie
,
PLATFORM_ID
,
TransferState
,
'
ORIGIN_URL
'
,
],
},
{
provide
:
Upload
,
useFactory
:
Upload
.
_
,
deps
:
[
HttpClient
],
deps
:
[
HttpClient
,
Cookie
],
},
{
provide
:
HTTP_INTERCEPTORS
,
...
...
@@ -88,6 +96,7 @@ export const MINDS_PROVIDERS: any[] = [
useClass
:
CookieHttpInterceptorService
,
multi
:
true
,
},
Cookie
,
{
provide
:
Storage
,
useFactory
:
Storage
.
_
,
...
...
This diff is collapsed.
webpack.server.config.js
View file @
6a3dac72
...
...
@@ -4,24 +4,15 @@ const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplaceme
const
path
=
require
(
'
path
'
);
const
webpack
=
require
(
'
webpack
'
);
const
nodeExternals
=
require
(
'
webpack-node-externals
'
);
module
.
exports
=
{
mode
:
'
none
'
,
entry
:
{
// This is our Express server for Dynamic universal
server
:
'
./server.ts
'
,
// This is an example of Static prerendering (generative)
},
target
:
'
node
'
,
resolve
:
{
extensions
:
[
'
.ts
'
,
'
.js
'
]
},
// Make sure we include all node_modules etc
externals
:
[
/node_modules/
,
nodeExternals
({
whitelist
:
[
/^@agm
\/
core/
,
/^hammerjs/
],
}),
],
resolve
:
{
extensions
:
[
'
.ts
'
,
'
.js
'
,
'
.json
'
]
},
output
:
{
// Puts the output at the root of the dist folder
path
:
path
.
join
(
__dirname
,
'
dist
'
),
...
...
This diff is collapsed.
Please
register
or
sign in
to comment