Skip to content

Commit

Permalink
feat(overthebox): unlink device
Browse files Browse the repository at this point in the history
ref: UXCT-268

Signed-off-by: Stephanie Moallic <stephanie.moallic@corp.ovh.com>
  • Loading branch information
Stephanie Moallic committed Jun 27, 2024
1 parent 88e97b4 commit 6eca824
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ export default class OverTheBoxDetailsCtrl {

this.guidesLink = this.OVERTHEBOX_DETAILS.guidesUrl.fr;

this.confirmUnlink = false;

this.$q
.all([
this.getServiceInfos(),
Expand Down Expand Up @@ -859,4 +861,32 @@ export default class OverTheBoxDetailsCtrl {
this.loaders.changingAutoUpgrade = false;
});
}

unlink() {
this.confirmUnlink = true;
}

cancel() {
this.confirmUnlink = false;
}

unlinkDevice() {
this.confirmUnlink = false;
return this.OverTheBoxGraphService.unlinkDevice(this.serviceName)
.then(() => {
// TODO: 5ba1d189-538a-40bf-90c6-4c9ca2ada311
this.TucToast.success(
this.$translate.instant('overTheBox_unlink_device_success'),
);
this.error.noDeviceLinked = false;
this.device = null;
})
.catch((err) => {
this.TucToast.error(
this.$translate.instant('overTheBox_unlink_device_error', {
errorMessage: err.data.message,
}),
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,26 @@
</button>
</div>
</form>
<button
class="btn btn-default no-transition"
data-translate="overTheBox_deviceId_unlink"
type="button"
title="{{::'overTheBox_deviceId_button_title' | translate }} {{::'overTheBox_deviceId_unlink' | translate }}"
data-ng-if="!$ctrl.device.editMode && $ctrl.device.deviceId"
data-ng-click="$ctrl.unlink()"
></button>
<oui-modal
data-ng-if="$ctrl.confirmUnlink"
data-primary-label="{{:: 'overTheBox_deviceId_unlink' | translate }}"
data-primary-action=":: $ctrl.unlinkDevice()"
data-secondary-label="{{:: 'overTheBox_cancel' | translate }}"
data-secondary-action=":: $ctrl.cancel()"
data-on-dismiss="$ctrl.cancel()"
>
<p
data-translate="overTheBox_confirm_unlink_device"
></p>
</oui-modal>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ export default class OverTheBoxDetailsService {
getDeviceHardware(serviceName) {
return this.$http.get(`/overTheBox/${serviceName}/device/hardware`);
}

unlinkDevice(serviceName) {
return this.$http.delete(`/overTheBox/${serviceName}/device`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,10 @@
"overthebox_caracteristics": "Caractéristiques",
"overTheBox_model_device": "Modèle du périphérique",
"overTheBox_detail_bandwidth": "Bande passante maximum",
"overTheBox_model_device_unknown": "Inconnu"
"overTheBox_model_device_unknown": "Inconnu",
"overTheBox_deviceId_unlink": "Dissocier",
"overTheBox_cancel": "Annuler",
"overTheBox_confirm_unlink_device": "Ce périphérique ne pourra plus se connecter ce service, en êtes-vous sûr?",
"overTheBox_unlink_device_error": "Nous n'avons pas pu dissocier le périphérique : {{errorMessage}}",
"overTheBox_unlink_device_success": "Votre périphérique a été dissocié avec succès."
}

0 comments on commit 6eca824

Please sign in to comment.