Skip to content

Commit

Permalink
Merge pull request #281 from opensds/development
Browse files Browse the repository at this point in the history
Merge development into master for Daito RC4 v0.9.0
  • Loading branch information
kumarashit authored Jan 3, 2020
2 parents 0cb0fde + 9b716f4 commit 25fa67e
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 59 deletions.
8 changes: 7 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ <h1>{{menuItem.title}}</h1>

<div *ngIf="showPrompt" style="padding:15px 20px; z-index: 99999; line-height:18px;position: fixed;bottom: 10px;left:10px;background:rgba(255,255,255,0.75); border-radius: 5px; box-shadow:0 0 10px rgba(0,0,0,0.3);">
<span>Uploading file [ {{fileName}} ]</span>
</div>
</div>
<ul style=" z-index: 99999; line-height:18px;position: fixed;bottom: 10px;left:10px;">
<li *ngFor="let downfile of downLoadArr;index as i" style="display: inline-block; padding:15px; background:rgba(255,255,255,0.75); border-radius: 5px; box-shadow:0 0 10px rgba(0,0,0,0.3);">
<span *ngIf="i==0">downloading file</span>
<span>[ {{downfile.name}} ]</span>
</li>
</ul>
13 changes: 12 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class AppComponent implements OnInit, AfterViewInit {
errorMsg: string = "";
showPrompt = false;
fileName: string = "";

downLoadArr = [];
tenantItems = [];
projectItemId;
userId;
Expand Down Expand Up @@ -175,6 +175,17 @@ export class AppComponent implements OnInit, AfterViewInit {
window['uploadPartArr'] = [];
window['isUpload'] = false;
let uploadNum = 0;
window['load'] = (file,id) => {
this.downLoadArr.push({
'name':file,
'id': id
})
}
window['disload'] = (file,id) =>{
this.downLoadArr = this.downLoadArr.filter((item)=>{
return item.id != id
})
}
window['startUpload'] = (selectFile, bucketId, options,folderId, cb) => {
window['isUpload'] = true;
this.showPrompt = true;
Expand Down
70 changes: 43 additions & 27 deletions src/app/business/block/bucket-detail/bucket-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,38 +458,54 @@ export class BucketDetailComponent implements OnInit {
window['canonicalString'](requestMethod, url,()=>{
let options: any = {};
this.getSignature(options);
options = {
headers: {
'Authorization': this.Signature,
'X-Auth-Date': this.kDate
},
responseType: 'arraybuffer' as 'arraybuffer'
}
this.httpClient.get(downloadUrl, options).subscribe((res)=>{
let blob = new Blob([res]);
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window['load'](file.Key,file.ETag)
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = "arraybuffer";
xhr.setRequestHeader('Authorization', this.Signature)
xhr.setRequestHeader('X-Auth-Date', this.kDate)
let msgs = this.msg
xhr.onload = function () {
if ((this as any).status === 200) {
let res = (this as any).response;
let blob = new Blob([res]);
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = ()=>{
if (typeof window.navigator.msSaveBlob !== 'undefined') {
window.navigator.msSaveBlob(blob, file.Key);
} else {
let URL = window.URL
let objectUrl = URL.createObjectURL(blob)
if (file.Key) {
let a = document.createElement('a')
a.href = objectUrl
a.download = file.Key
document.body.appendChild(a)
a.click()
a.remove()
} else {
let URL = window.URL
let objectUrl = URL.createObjectURL(blob)
if (file.Key) {
let a = document.createElement('a')
a.href = objectUrl
a.download = file.Key
document.body.appendChild(a)
a.click()
a.remove()
}else {
navigator.msSaveBlob(blob);
}
}
}
window['disload'](file.Key,file.ETag)
msgs.success(`${file.Key} downloaded successfully`)
}else{
window['disload'](file.Key,file.ETag)
msgs.error(`${file.Key} download failed. The network may be unstable. Please try again later.`);
}
},
(error)=>{
console.log('error');
this.msg.error("The download failed. The network may be unstable. Please try again later.");
});
};
xhr.send()
xhr.onerror = ()=>{
window['disload'](file.Key,file.ETag)
msgs.error(`${file.Key} download failed. The network may be unstable. Please try again later.`);
}
xhr.onloadend=()=>{
window['disload'](file.Key)
}
})
});


}
//Gets the name of the folder
folderNameOnChanged(folder){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export class LifeCycleComponent implements OnInit {
let lifeCycleAll = {
ObjectKey: item.ID,
Status: item.Status,
prefix:item.Filter.Prefix,
newPrefix: this.getLifeCyclePrefix(item, dialog, cycle),
Rules: this.getLifeCycleRule(item)
}
Expand All @@ -218,6 +219,7 @@ export class LifeCycleComponent implements OnInit {
let lifeCycleAll = {
ObjectKey: lifeCycleArr.ID,
Status: lifeCycleArr.Status,
prefix:lifeCycleArr.Filter.Prefix,
newPrefix: this.getLifeCyclePrefix(lifeCycleArr, dialog, cycle),
Rules: this.getLifeCycleRule(lifeCycleArr)
}
Expand Down Expand Up @@ -568,7 +570,7 @@ export class LifeCycleComponent implements OnInit {
let Rules = {
Rule: {
ID: value.name,
Filter: { Prefix: value.Prefix ? value.Prefix : (value.newPrefix ? value.newPrefix : value.prefix)},
Filter: { Prefix: value.prefix ? value.prefix : (value.newPrefix && value.newPrefix!='--' ? value.newPrefix : value.prefix)},
Status: (((this.transChecked && this.transOptions.length != 0) || this.expirChecked || this.expirCleanUp) && value.enabled) ? "Enabled" :
value.Status ? value.Status : "Disabled"
}
Expand Down
27 changes: 21 additions & 6 deletions src/app/business/block/buckets.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class BucketsComponent implements OnInit{
allBuckets = [];
createBucketForm:FormGroup;
errorMessage :Object;
validRule: any;
createBucketDisplay=false;
showLife = false;
backendsOption = [];
Expand Down Expand Up @@ -93,16 +94,26 @@ export class BucketsComponent implements OnInit{
private msg: MsgBoxService
){
this.errorMessage = {
"name": { required: "Name is required.",isExisted:"Name is existing" },
"name": {
required: "Name is required.",
isExisted:"Name is existing",
minlength: "The bucket name should have minimum 3 characters.",
maxlength: "The bucket name can have maximum 63 characters.",
pattern: "Please enter valid bucket name."
},
"backend_type": { required: "Type is required." },
"backend":{ required: "Backend is required." },
"destBucket":{ required: "Destination Bucket is required." },
};
this.validRule = {
'validName' : '^[a-z0-9][a-z0-9\.\-]{1,61}[a-z0-9]$'
};
this.createBucketForm = this.fb.group({
"name":["",{validators:[Validators.required, Validators.minLength(3), Validators.maxLength(63), Validators.pattern(this.validRule.validName),
Utils.isExisted(this.allBucketNameForCheck)], updateOn:'change'}],
"backend":["",{validators:[Validators.required], updateOn:'change'}],
"backend_type":["",{validators:[Validators.required], updateOn:'change'}],
"name":["",{validators:[Validators.required,Utils.isExisted(this.allBucketNameForCheck)], updateOn:'change'}],
"version": [false, { validators: [Validators.required], updateOn: 'change' }],
"version": [false],
"encryption": [false, { validators: [Validators.required], updateOn: 'change' }],
"sse":["",{}],
});
Expand Down Expand Up @@ -375,7 +386,7 @@ export class BucketsComponent implements OnInit{
let options: any = {};
this.getSignature(options);
options.headers.set('Content-Type','application/xml');
this.BucketService.createBucket(this.createBucketForm.value.name,xmlStr,options).subscribe(()=>{
this.BucketService.createBucket(this.createBucketForm.value.name,xmlStr,options).subscribe((res)=>{
this.createBucketDisplay = false;
/* Add the PUT Encryption Call here before fetching the updated list of Buckets */
if(this.enableEncryption){
Expand All @@ -387,9 +398,13 @@ export class BucketsComponent implements OnInit{
if(!this.enableEncryption && !this.enableVersion){
this.getBuckets();
}

this.msgs = [];
this.msgs.push({severity: 'success', summary: 'Success', detail: 'Bucket has been created successfully.'});
/* Call the getBuckets call in the success of the encryption call */

},(error)=>{
this.msgs = [];
this.msgs.push({severity: 'error', summary: "Error", detail: error._body});
});
})
})
Expand Down Expand Up @@ -519,7 +534,7 @@ export class BucketsComponent implements OnInit{
"encryption": false
}
);
this.createBucketForm.controls['name'].setValidators([Validators.required,Utils.isExisted(this.allBucketNameForCheck)]);
this.createBucketForm.controls['name'].setValidators([Validators.required, Validators.minLength(3), Validators.maxLength(63), Validators.pattern(this.validRule.validName), Utils.isExisted(this.allBucketNameForCheck)]);
this.getTypes();
}
deleteBucket(bucket){
Expand Down
18 changes: 3 additions & 15 deletions src/app/business/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,10 @@
<input id="name" type="text" name="name" formControlName="name" pInputText />
</form-item>
<form-item label="Type" [required]="true">
<p-dropdown [style]="{'min-width':'220px'}" placeholder="Please select" formControlName="type" [options]="allTypes" ></p-dropdown>
<p-dropdown [style]="{'min-width':'220px'}" (onChange)="selectOption()" placeholder="Please select" formControlName="type" [options]="allTypes" ></p-dropdown>
</form-item>
<form-item label="Region" [required]="true">
<input id="region" type="text" name="region" formControlName="region" pInputText />
</form-item>
<form-item label="Endpoint" [required]="true">
<input id="endpoint" type="text" name="endpoint" formControlName="endpoint" pInputText />
</form-item>
<form-item label="Bucket" [required]="true">
<input id="bucket" type="text" name="bucket" formControlName="bucket" placeholder="Bucket name" pInputText />
</form-item>
<form-item label="Access Key" [required]="true">
<input id="accessKey" type="text" name="accessKey" formControlName="ak" pInputText />
</form-item>
<form-item label="Secret Key" [required]="true">
<input id="secretKey" type="password" name="secretKey" formControlName="sk" pInputText />
<form-item *ngFor="let item of formItemCopy" [label]="item.label" [required]="item.required">
<input [id]="item.id" [type]="item.type" [name]="item.name" [formControlName]="item.formControlName" pInputText />
</form-item>
</form>
<div style="margin-top:100px;">
Expand Down
77 changes: 71 additions & 6 deletions src/app/business/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class HomeComponent implements OnInit {
bucketsCount:0,
migrationCount:0
}
backendForm :FormGroup;
backendForm;
typeDetail = [];
selectedType:any;
selectedRegions = [];
Expand All @@ -45,6 +45,55 @@ export class HomeComponent implements OnInit {
selectedBackend:any;
cloud_type = [];
allBackendNameForCheck=[];
formItemCopy = [];
formItems = [
{
label: 'Region',
required: 'true',
id: 'region',
type: 'text',
name: 'region',
formControlName: 'region',
arr:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','gcp-s3','ibm-cos']
},
{
label: 'Endpoint',
required: 'true',
id: 'endpoint',
type: 'text',
name: 'endpoint',
formControlName: 'endpoint',
arr:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','gcp-s3','ibm-cos','yig']
},
{
label: 'Bucket',
required: 'true',
id: 'bucket',
type: 'text',
name: 'bucket',
formControlName: 'bucket',
arr:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','gcp-s3','ibm-cos']
},
{
label: 'Access Key',
required: 'true',
id: 'accessKey',
type: 'text',
name: 'accessKey',
formControlName: 'ak',
arr:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','gcp-s3','ibm-cos']
},
{
label: 'Secret Key',
required: 'true',
id: 'secretKey',
type: 'password',
name: 'secretKey',
formControlName: 'sk',
arr:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','gcp-s3','ibm-cos']
},
]


@ViewChild("path") path: ElementRef;
@ViewChild("cloud_aws") c_AWS: ElementRef;
Expand Down Expand Up @@ -87,11 +136,11 @@ export class HomeComponent implements OnInit {
this.backendForm = this.fb.group({
"name":['', {validators:[Validators.required,Utils.isExisted(this.allBackendNameForCheck)]}],
"type":['',{validators:[Validators.required]}],
"region":['',{validators:[Validators.required], updateOn:'change'}],
"endpoint":['',{validators:[Validators.required], updateOn:'change'}],
"bucket":['',{validators:[Validators.required], updateOn:'change'}],
"ak":['',{validators:[Validators.required], updateOn:'change'}],
"sk":['',{validators:[Validators.required], updateOn:'change'}],
"region":new FormControl([]),
"endpoint":new FormControl([]),
"bucket":new FormControl([]),
"ak":new FormControl([]),
"sk":new FormControl([]),
});
this.modifyBackendForm = this.fb.group({
"ak":['',{validators:[Validators.required], updateOn:'change'}],
Expand Down Expand Up @@ -150,6 +199,20 @@ export class HomeComponent implements OnInit {
});
this.initBucket2backendAnd2Type();
}
selectOption(){
this.formItemCopy = []
let selectOptionItem =this.backendForm && this.backendForm.value.type
this.formItems.forEach((item)=>{
item.arr.forEach((it)=>{
if(it == selectOptionItem){
this.formItemCopy.push(item)
this.backendForm.controls[`${item.formControlName}`].setValidators(Validators.required);
}else{
this.backendForm.controls[`${item.formControlName}`].setValidators('');
}
})
})
}

initBucket2backendAnd2Type(){
window['getAkSkList'](()=>{
Expand Down Expand Up @@ -375,10 +438,12 @@ export class HomeComponent implements OnInit {
this.http.get('v1/{project_id}/backends').subscribe((res)=>{
let backends = res.json().backends ? res.json().backends :[];
this.initBackendsAndNum(backends);
this.formItemCopy = []
});
});
}
showRegister(){
this.formItemCopy = []
this.showRegisterFlag = true;
this.backendForm.reset();
this.backendForm.controls['name'].setValidators([Validators.required,Utils.isExisted(this.allBackendNameForCheck)]);
Expand Down
5 changes: 3 additions & 2 deletions src/app/shared/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ export const Consts = {
BUCKET_TYPE:new Map<string,string>(),
BYTES_PER_CHUNK : 1024 * 1024 * 5,
TIMEOUT: 30 * 60 * 1000,
CLOUD_TYPE:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','ibm-cos','gcp', 'yig'],
CLOUD_TYPE:['aws-s3','azure-blob','hw-obs','fusionstorage-object','ceph-s3','ibm-cos','gcp-s3', 'yig'],
TYPE_SVG:{
"aws-s3":'aws.svg',
"hw-obs":"huawei.svg",
"azure-blob":'azure.svg',
"fusionstorage-object":"huawei.svg",
"ceph-s3": "ceph.svg",
"ibm-cos": "ibm.svg",
"gcp": "GCP.jpg"
"gcp-s3": "google.svg",
"yig": "yig.png"
},
CLOUD_TYPE_NAME: {
'aws-s3': 'AWS S3',
Expand Down
Binary file added src/assets/business/images/common/yig.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25fa67e

Please sign in to comment.