Skip to content

Commit fbbd8f1

Browse files
committed
feat(sas): Add UI for SAS workspaces
1 parent f2caa7a commit fbbd8f1

27 files changed

+314
-29
lines changed

config.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type SpawnerFormDefaults struct {
1010
Image Image `yaml:"image" json:"image"`
1111
ImageGroupOne ImageGroup `yaml:"imageGroupOne" json:"imageGroupOne"`
1212
ImageGroupTwo ImageGroup `yaml:"imageGroupTwo" json:"imageGroupTwo"`
13+
ImageGroupThree ImageGroup `yaml:"imageGroupThree" json:"imageGroupThree"`
1314
AllowCustomImage bool `yaml:"allowCustomImage" json:"allowCustomImage"`
1415
ImagePullPolicy ImagePullPolicy `yaml:"imagePullPolicy" json:"imagePullPolicy"`
1516
CPU CPU `yaml:"cpu" json:"cpu"`
@@ -100,8 +101,14 @@ type Image struct {
100101
}
101102

102103
type ImageGroup struct {
103-
Value string `yaml:"value" json:"value"`
104-
Options []string `yaml:"options" json:"options"`
104+
DisabledMessage map[string]string `yaml:"disabledMessage" json:"disabledMessage,omitempty"`
105+
EnabledCondition *EnabledCondition `yaml:"enabledCondition" json:"enabledCondition,omitempty"`
106+
Value string `yaml:"value" json:"value"`
107+
Options []string `yaml:"options" json:"options"`
108+
}
109+
110+
type EnabledCondition struct {
111+
Labels map[string]string `yaml:"labels" json:"labels,omitempty"`
105112
}
106113

107114
type Shm struct {

frontend/common/kubeflow-common-lib/projects/kubeflow/src/assets/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"serverType": "Server Type",
4646
"useJupyterLabBasedServer": "Use JupyterLab based server",
4747
"useGroupOneBasedServer": "Use Group One based server",
48-
"useGroupTwoBasedServer": "Use Group Two based server"
48+
"useGroupTwoBasedServer": "Use Group Two based server",
49+
"useGroupThreeBasedServer": "Use Group Three based server"
4950
},
5051
"formName": {
5152
"nameDesc": "Specify the name of the Notebook Server and the Namespace it will belong to."

frontend/common/kubeflow-common-lib/projects/kubeflow/src/assets/fr.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"serverType": "Type de serveur",
4646
"useJupyterLabBasedServer": "Utiliser le serveur basé sur JupyterLab",
4747
"useGroupOneBasedServer": "Utiliser le serveur basé sur le groupe un",
48-
"useGroupTwoBasedServer": "Utiliser le serveur basé sur le groupe deux"
48+
"useGroupTwoBasedServer": "Utiliser le serveur basé sur le groupe deux",
49+
"useGroupThreeBasedServer": "Utiliser le serveur basé sur le groupe trois"
4950
},
5051
"formName": {
5152
"nameDesc": "Spécifier le nom du serveur bloc-notes et l'espace de noms dont il fera partie."

frontend/jupyter/package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/jupyter/src/app/app.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { TranslateService } from '@ngx-translate/core';
88
})
99
export class AppComponent {
1010
constructor(private translate: TranslateService) {
11-
const currentLanguage = this.translate.getBrowserLang();
12-
const lang = currentLanguage.match(/en|fr/)? currentLanguage : 'en';
13-
translate.setDefaultLang(lang);
11+
translate.setDefaultLang('en');
12+
translate.use(this.translate.getBrowserLang());
1413
}
1514
title = 'frontend';
1615
}

frontend/jupyter/src/app/pages/form/form-default/form-default.component.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
<app-form-image
1010
[parentForm]="formCtrl"
1111
[images]="config?.image?.options"
12-
[imagesGroupOne]="config?.imageGroupOne?.options"
13-
[imagesGroupTwo]="config?.imageGroupTwo?.options"
12+
[imagesGroupOne]="config?.imageGroupOne"
13+
[imagesGroupTwo]="config?.imageGroupTwo"
14+
[imagesGroupThree]="config?.imageGroupThree"
1415
[allowCustomImage]="config?.allowCustomImage"
1516
[hideRegistry]="config?.hideRegistry"
1617
[hideTag]="config?.hideTag"
18+
[nsMetadata]="nsMetadata"
1719
></app-form-image>
1820

1921
<app-form-cpu-ram

frontend/jupyter/src/app/pages/form/form-default/form-default.component.ts

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { getFormDefaults, initFormControls } from './utils';
1414
import { JWABackendService } from 'src/app/services/backend.service';
1515
import { environment } from '@app/environment';
1616
import { TranslateService } from '@ngx-translate/core';
17+
import { V1Namespace } from '@kubernetes/client-node';
1718

1819
@Component({
1920
selector: 'app-form-default',
@@ -36,6 +37,7 @@ export class FormDefaultComponent implements OnInit, OnDestroy {
3637
subscriptions = new Subscription();
3738

3839
readonlySpecs: boolean;
40+
nsMetadata: V1Namespace;
3941

4042
constructor(
4143
public namespaceService: NamespaceService,
@@ -71,6 +73,11 @@ export class FormDefaultComponent implements OnInit, OnDestroy {
7173
this.backend.getVolumes(namespace).subscribe(pvcs => {
7274
this.pvcs = pvcs;
7375
});
76+
77+
this.backend.getNSMetadata(namespace).subscribe(nsMetadata => {
78+
this.nsMetadata = nsMetadata;
79+
});
80+
7481
}),
7582
);
7683

@@ -121,11 +128,15 @@ export class FormDefaultComponent implements OnInit, OnDestroy {
121128
} else if (notebook.serverType === 'group-two') {
122129
// Set notebook image from imageGroupTwo
123130
notebook.image = notebook.imageGroupTwo;
131+
} else if (notebook.serverType === 'group-three') {
132+
// Set notebook image from imageGroupThree
133+
notebook.image = notebook.imageGroupThree;
124134
}
125135

126136
// Remove unnecessary images from the request sent to the backend
127137
delete notebook.imageGroupOne;
128138
delete notebook.imageGroupTwo;
139+
delete notebook.imageGroupThree;
129140

130141
// Ensure CPU input is a string
131142
if (typeof notebook.cpu === 'number') {
@@ -177,16 +188,17 @@ export class FormDefaultComponent implements OnInit, OnDestroy {
177188
this.router.navigate(['/']);
178189
});
179190
}
180-
// Automatically set values of CPU and Memory if GPU is 1
181-
checkGPU(gpu: string) {
182-
if (gpu == "none") {
183-
this.readonlySpecs = false;
184-
} else {
185-
this.readonlySpecs = true;
186-
this.formCtrl.get("cpu").setValue("4");
187-
this.formCtrl.get("memory").setValue("96");
188-
}
191+
192+
// Automatically set values of CPU and Memory if GPU is 1
193+
checkGPU(gpu: string) {
194+
if (gpu == "none") {
195+
this.readonlySpecs = false;
196+
} else {
197+
this.readonlySpecs = true;
198+
this.formCtrl.get("cpu").setValue("4");
199+
this.formCtrl.get("memory").setValue("96");
189200
}
201+
}
190202

191203
onCancel() {
192204
this.router.navigate(['/']);

frontend/jupyter/src/app/pages/form/form-default/form-image/form-image.component.html

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
attr.aria-label="{{
3232
'jupyter.formImage.useGroupOneBasedServer' | translate
3333
}}"
34+
[disabled]="!shouldEnable(imagesGroupOne?.enabledCondition)"
35+
[matTooltip]="!shouldEnable(imagesGroupOne?.enabledCondition) ? getDisabledMessage('group-one') : ''"
36+
[class.toolbar-icon-disabled]="!shouldEnable(imagesGroupOne?.enabledCondition)"
3437
>
3538
<mat-icon class="server-type" svgIcon="group-one"></mat-icon>
3639
</mat-button-toggle>
@@ -39,9 +42,23 @@
3942
attr.aria-label="{{
4043
'jupyter.formImage.useGroupTwoBasedServer' | translate
4144
}}"
45+
[disabled]="!shouldEnable(imagesGroupTwo?.enabledCondition)"
46+
[matTooltip]="!shouldEnable(imagesGroupTwo?.enabledCondition) ? getDisabledMessage('group-two') : ''"
47+
[class.toolbar-icon-disabled]="!shouldEnable(imagesGroupTwo?.enabledCondition)"
4248
>
4349
<mat-icon class="server-type" svgIcon="group-two"></mat-icon>
4450
</mat-button-toggle>
51+
<mat-button-toggle
52+
value="group-three"
53+
attr.aria-label="{{
54+
'jupyter.formImage.useGroupThreeBasedServer' | translate
55+
}}"
56+
[disabled]="!shouldEnable(imagesGroupThree?.enabledCondition)"
57+
[matTooltip]="!shouldEnable(imagesGroupThree?.enabledCondition) ? getDisabledMessage('group-three') : ''"
58+
[class.toolbar-icon-disabled]="!shouldEnable(imagesGroupThree?.enabledCondition)"
59+
>
60+
<mat-icon class="server-type" svgIcon="group-three"></mat-icon>
61+
</mat-button-toggle>
4562
</mat-button-toggle-group>
4663
</div>
4764

@@ -83,7 +100,7 @@
83100
[formControl]="parentForm.get('imageGroupOne')"
84101
>
85102
<mat-option
86-
*ngFor="let img of imagesGroupOne"
103+
*ngFor="let img of imagesGroupOne.options"
87104
[value]="img"
88105
[matTooltip]="img"
89106
>
@@ -110,7 +127,7 @@
110127
[formControl]="parentForm.get('imageGroupTwo')"
111128
>
112129
<mat-option
113-
*ngFor="let img of imagesGroupTwo"
130+
*ngFor="let img of imagesGroupTwo.options"
114131
[value]="img"
115132
[matTooltip]="img"
116133
>
@@ -122,6 +139,33 @@
122139
</mat-error>
123140
</mat-form-field>
124141

142+
<mat-form-field
143+
class="wide"
144+
appearance="outline"
145+
*ngIf="
146+
!parentForm?.value.customImageCheck &&
147+
parentForm?.value.serverType === 'group-three'
148+
"
149+
>
150+
<!-- If readonly, then make it an input element instead of select -->
151+
<mat-label>{{ 'common.image' | translate }}</mat-label>
152+
<mat-select
153+
placeholder="{ 'jupyter.formImage.imageDocker' | translate }}"
154+
[formControl]="parentForm.get('imageGroupThree')"
155+
>
156+
<mat-option
157+
*ngFor="let img of imagesGroupThree.options"
158+
[value]="img"
159+
[matTooltip]="img"
160+
>
161+
{{ imageDisplayName(img) }}
162+
</mat-option>
163+
</mat-select>
164+
<mat-error>
165+
{{ 'jupyter.formImage.errorImageRequired' | translate }}
166+
</mat-error>
167+
</mat-form-field>
168+
125169
<mat-form-field
126170
class="wide"
127171
appearance="outline"

frontend/jupyter/src/app/pages/form/form-default/form-image/form-image.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,12 @@
77
margin-bottom: 1rem;
88
width: fit-content;
99
}
10+
11+
.toolbar-icon-disabled {
12+
fill: gray;
13+
opacity: .5;
14+
}
15+
16+
p {
17+
margin-top: -5px;
18+
}

0 commit comments

Comments
 (0)