|
sasJsConfig
|
Type : SASjsConfig
|
Default value : new SASjsConfig()
|
|
|
Outputs
|
onNavigateToHome
|
Type : EventEmitter<any>
|
|
|
Methods
|
getServerInfo
|
getServerInfo()
|
|
|
Fethes the sasjs server instance info
|
|
getUserGroups
|
getUserGroups()
|
|
|
Fetches user groups from the usernav/usergroupsbymember service
|
|
dcAdminGroup
|
Type : string
|
Default value : 'DCDEFAULT'
|
|
|
|
dcAdminGroupList
|
Type : SASGroup[]
|
Default value : []
|
|
|
|
dcDirectory
|
Type : string
|
Default value : ''
|
|
|
|
loading
|
Type : boolean
|
Default value : false
|
|
|
|
METAPERSON
|
Type : string
|
Default value : 'n/a'
|
|
|
|
METAUSER
|
Type : string
|
Default value : 'n/a'
|
|
|
|
showLogout
|
Type : boolean
|
Default value : false
|
|
|
|
SYSHOSTNAME
|
Type : string
|
Default value : 'n/a'
|
|
|
|
SYSUSERID
|
Type : string
|
Default value : 'n/a'
|
|
|
|
SYSVLONG
|
Type : string
|
Default value : 'n/a'
|
|
|
|
tmpDirectories
|
Type : object
|
Default value : {
linux: '/tmp/DataController',
windows: 'C:\\DataController'
}
|
|
|
import { Location } from '@angular/common'
import {
Component,
EventEmitter,
Input,
OnInit,
Output,
ViewEncapsulation
} from '@angular/core'
import SASjs, { SASjsConfig } from '@sasjs/adapter'
import { ServerType } from '@sasjs/utils/types/serverType'
import { DcAdapterSettings } from 'src/app/models/DcAdapterSettings'
import { RequestWrapperResponse } from 'src/app/models/request-wrapper/RequestWrapperResponse'
import { SASGroup } from 'src/app/models/sas/public-getgroups.model'
import { SASjsApiServerInfo } from 'src/app/models/sasjs-api/SASjsApiServerInfo.model'
import { SasService } from 'src/app/services/sas.service'
import { SasjsService } from 'src/app/services/sasjs.service'
@Component({
selector: 'app-sasjs-configurator',
templateUrl: './sasjs-configurator.component.html',
styleUrls: ['./sasjs-configurator.component.scss'],
encapsulation: ViewEncapsulation.None,
standalone: false
})
export class SasjsConfiguratorComponent implements OnInit {
@Input() sasJs!: SASjs
@Input() sasJsConfig: SASjsConfig = new SASjsConfig()
@Input() dcAdapterSettings: DcAdapterSettings | undefined
@Output() onNavigateToHome: EventEmitter<any> = new EventEmitter<any>()
dcDirectory: string = ''
dcAdminGroup: string = 'DCDEFAULT'
METAPERSON: string = 'n/a'
METAUSER: string = 'n/a'
SYSUSERID: string = 'n/a'
SYSHOSTNAME: string = 'n/a'
SYSVLONG: string = 'n/a'
dcAdminGroupList: SASGroup[] = []
loading: boolean = false
showLogout: boolean = false
tmpDirectories = {
linux: '/tmp/DataController',
windows: 'C:\\DataController'
}
constructor(
private sasService: SasService,
private sasjsService: SasjsService,
private location: Location
) {}
ngOnInit(): void {
this.getUserGroups()
this.getServerInfo()
}
/**
* Fethes the sasjs server instance info
*/
getServerInfo() {
this.sasjsService
.getServerInfo()
.subscribe((serverInfo: SASjsApiServerInfo) => {
if (serverInfo.mode !== 'desktop') this.showLogout = true
})
}
/**
* Fetches user groups from the `usernav/usergroupsbymember` service
*/
getUserGroups() {
this.loading = true
this.sasService.request('usernav/usergroupsbymember', null).then(
(res: RequestWrapperResponse) => {
this.METAPERSON = res.adapterResponse.MF_GETUSER
this.SYSUSERID = res.adapterResponse.SYSUSERID
this.SYSHOSTNAME = res.adapterResponse.SYSHOSTNAME
this.SYSVLONG = res.adapterResponse.SYSVLONG
/*
We would like to present a default DCPATH (deployment path) to the
user who is installing Data Controller. This path should be
appropriate to the server type, ie windows or linux.
We can use the SYSSCPL variable from the service response above, and
derive the OS based on the first letter.
The list of values is available here:
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/mcrolref/n0e7s8lf147kazn17u45trpwb6sw.htm
*/
this.dcDirectory =
this.tmpDirectories[
['L', 'H', 'A', 'S'].includes(
res.adapterResponse.SYSSCPL.substring(0, 1)
)
? 'linux'
: 'windows'
]
this.dcAdminGroupList = res.adapterResponse.groups
this.dcAdminGroup = this.dcAdminGroupList[0].GROUPNAME
this.loading = false
},
(err: any) => {
this.loading = false
}
)
}
/**
* Creating database
*/
makeData() {
// Debug is ALWAYS enabled for this service. The makedata service runs only once
// during deployment configuration, so full debug output (131) is always wanted
// to help diagnose any issues. This is NOT temporary — do not remove or gate it.
const _debug = '&_debug=131'
let executor = this.sasService.getExecutionPath()
const root = this.sasJsConfig.appLoc
let serverUrl = this.sasJsConfig.serverUrl
let dcDirectory = this.dcDirectory
if (this.sasJsConfig.serverType === ServerType.Sasjs) {
this.sasService.sasjsMakedataChecking().then((success: boolean) => {
if (!!success) {
this.location.replaceState('/')
location.reload()
}
})
} else if (this.sasJsConfig.serverType === ServerType.Sas9) {
serverUrl = ''
executor = window.location.origin + executor + '/'
dcDirectory = encodeURIComponent(this.dcDirectory)
}
const url = `${
serverUrl ? serverUrl : ''
}${executor}?_program=${root}/services/admin/makedata&admin=${
this.dcAdminGroup
}&path=${dcDirectory}${_debug}`
window.open(url, '_blank')
}
logout() {
this.sasService.logout()
}
}
@if (loading) {
<div class="thinProgress progresStatic progress loop">
<progress></progress>
</div>
}
<h4 class="text-center my-15">Sasjs Deploy</h4>
<hr class="light" />
<p class="m-0">
To configure Data Controller for SAS©, please provide the following details:
</p>
<p class="m-0 mt-10">
Please specify a physical directory (on the
<strong> {{ SYSHOSTNAME }}</strong>
compute server) below, to which user
<strong>{{ SYSUSERID }}</strong> can write, on behalf of Data Controller.
</p>
<label class="mt-20 clr-control-label">DC Staging Directory</label>
<div class="mb-10 clr-control-container">
<div class="clr-input-wrapper">
<input
class="clr-input"
placeholder="Type in directory"
[(ngModel)]="dcDirectory"
/>
</div>
<!-- <button
(click)="directoryBrowse.click()"
class="mt-15 text-center"
class="btn btn-sm btn-outline"
>
Browse
</button>
<input #directoryBrowse hidden (change)="dirChange($event)" type="file" id="ctrl" webkitdirectory directory multiple/> -->
</div>
<p class="m-0 mt-10">
Below are the list of groups to which you belong. The group you select will
become the Data Controller Admin Group, and everyone in it will have
unrestricted access to Data Controller.
</p>
<label class="mt-20 clr-control-label">Data Controller Admin group</label>
<clr-select-container class="mb-10 mt-0 w-50vw">
<select [(ngModel)]="dcAdminGroup" clrSelect>
@for (adminGroup of dcAdminGroupList; track adminGroup) {
<option [value]="adminGroup.GROUPNAME">
{{ adminGroup.GROUPNAME }} - {{ adminGroup.GROUPDESC }}
</option>
}
</select>
</clr-select-container>
<p class="m-0 mt-10">
Now, create the target directory and deploy the control library using the
admin group selected above:
</p>
<div class="clr-flex">
<button (click)="makeData()" class="btn btn-success mt-15 text-center">
SUBMIT
</button>
</div>
<hr class="light" />
<div class="card-text pb-10">
<p>You are connected with the following credentials:</p>
<ul>
<li>METAPERSON: {{ METAPERSON }}</li>
<li>SYSUSERID: {{ SYSUSERID }}</li>
<li>SYSHOSTNAME: {{ SYSHOSTNAME }}</li>
<li>SYSVLONG: {{ SYSVLONG }}</li>
</ul>
</div>
Legend
Html element with directive